1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
using Test;
using System;
using System.Collections;
using System.Collections.Generic;
internal sealed class ServerI : ServerDisp_
{
internal ServerI(Ice.Communicator communicator)
{
_communicator = communicator;
}
public override void
noCert(Ice.Current current)
{
try
{
IceSSL.ConnectionInfo info = (IceSSL.ConnectionInfo)current.con.getInfo();
test(info.certs == null);
}
catch(Ice.LocalException)
{
test(false);
}
}
public override void
checkCert(string subjectDN, string issuerDN, Ice.Current current)
{
try
{
IceSSL.ConnectionInfo info = (IceSSL.ConnectionInfo)current.con.getInfo();
test(info.verified);
test(info.certs.Length == 2 &&
info.certs[0].Subject.Equals(subjectDN) &&
info.certs[0].Issuer.Equals(issuerDN));
}
catch(Ice.LocalException)
{
test(false);
}
}
public override void
checkCipher(string cipher, Ice.Current current)
{
try
{
IceSSL.ConnectionInfo info = (IceSSL.ConnectionInfo)current.con.getInfo();
test(info.cipher.Equals(cipher));
}
catch(Ice.LocalException)
{
test(false);
}
}
internal void destroy()
{
_communicator.destroy();
}
private static void test(bool b)
{
if (!b)
{
throw new Exception();
}
}
private Ice.Communicator _communicator;
}
internal sealed class ServerFactoryI : ServerFactoryDisp_
{
private static void test(bool b)
{
if (!b)
{
throw new Exception();
}
}
public ServerFactoryI(string defaultDir)
{
_defaultDir = defaultDir;
}
public override ServerPrx createServer(Dictionary<string, string> props, Ice.Current current)
{
Ice.InitializationData initData = new Ice.InitializationData();
initData.properties = Ice.Util.createProperties();
foreach(string key in props.Keys)
{
initData.properties.setProperty(key, props[key]);
}
initData.properties.setProperty("IceSSL.DefaultDir", _defaultDir);
string[] args = new string[0];
Ice.Communicator communicator = Ice.Util.initialize(ref args, initData);
Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("ServerAdapter", "ssl");
ServerI server = new ServerI(communicator);
Ice.ObjectPrx obj = adapter.addWithUUID(server);
_servers[obj.ice_getIdentity()] = server;
adapter.activate();
return ServerPrxHelper.uncheckedCast(obj);
}
public override void destroyServer(ServerPrx srv, Ice.Current current)
{
Ice.Identity key = srv.ice_getIdentity();
if(_servers.Contains(key))
{
ServerI server = _servers[key] as ServerI;
server.destroy();
_servers.Remove(key);
}
}
public override void shutdown(Ice.Current current)
{
test(_servers.Count == 0);
current.adapter.getCommunicator().shutdown();
}
private string _defaultDir;
private Hashtable _servers = new Hashtable();
}
|