1 // **********************************************************************
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
8 // **********************************************************************
11 #include <IceUtil/Thread.h>
13 #include <TestCommon.h>
14 #include <IceSSL/Plugin.h>
19 ServerI::ServerI(const CommunicatorPtr
& communicator
) :
20 _communicator(communicator
)
25 ServerI::noCert(const Ice::Current
& c
)
29 IceSSL::NativeConnectionInfoPtr info
= IceSSL::NativeConnectionInfoPtr::dynamicCast(c
.con
->getInfo());
30 test(info
->nativeCerts
.size() == 0);
32 catch(const Ice::LocalException
&)
39 ServerI::checkCert(const string
& subjectDN
, const string
& issuerDN
, const Ice::Current
& c
)
43 IceSSL::NativeConnectionInfoPtr info
= IceSSL::NativeConnectionInfoPtr::dynamicCast(c
.con
->getInfo());
44 test(info
->nativeCerts
.size() == 2 &&
45 info
->nativeCerts
[0]->getSubjectDN() == IceSSL::DistinguishedName(subjectDN
) &&
46 info
->nativeCerts
[0]->getIssuerDN() == IceSSL::DistinguishedName(issuerDN
));
48 catch(const Ice::LocalException
&)
55 ServerI::checkCipher(const string
& cipher
, const Ice::Current
& c
)
59 IceSSL::NativeConnectionInfoPtr info
= IceSSL::NativeConnectionInfoPtr::dynamicCast(c
.con
->getInfo());
60 test(info
->cipher
.compare(0, cipher
.size(), cipher
) == 0);
62 catch(const Ice::LocalException
&)
71 _communicator
->destroy();
75 ServerFactoryI::createServer(const Test::Properties
& props
, const Current
& current
)
77 InitializationData initData
;
78 initData
.properties
= createProperties();
79 for(Test::Properties::const_iterator p
= props
.begin(); p
!= props
.end(); ++p
)
81 initData
.properties
->setProperty(p
->first
, p
->second
);
84 CommunicatorPtr communicator
= initialize(initData
);
85 ObjectAdapterPtr adapter
= communicator
->createObjectAdapterWithEndpoints("ServerAdapter", "ssl");
86 ServerIPtr server
= new ServerI(communicator
);
87 ObjectPrx obj
= adapter
->addWithUUID(server
);
88 _servers
[obj
->ice_getIdentity()] = server
;
91 return Test::ServerPrx::uncheckedCast(obj
);
95 ServerFactoryI::destroyServer(const Test::ServerPrx
& srv
, const Ice::Current
&)
97 map
<Identity
, ServerIPtr
>::iterator p
= _servers
.find(srv
->ice_getIdentity());
98 if(p
!= _servers
.end())
100 p
->second
->destroy();
106 ServerFactoryI::shutdown(const Ice::Current
& current
)
108 test(_servers
.empty());
109 current
.adapter
->getCommunicator()->shutdown();