/// <exception cref="System.Exception"></exception>
 public virtual void SetUp()
 {
     _serverSocket = _plainSocketFactory.CreateServerSocket(0);
     _port         = _serverSocket.GetLocalPort();
     _client       = new Socket4Adapter(_plainSocketFactory.CreateSocket("localhost", _port)
                                        );
     _server = new Socket4Adapter(_serverSocket.Accept());
 }
Beispiel #2
0
 /// <exception cref="System.Exception"></exception>
 public virtual void SetUp()
 {
     _serverSocket = _plainSocketFactory.CreateServerSocket(0);
     _port = _serverSocket.GetLocalPort();
     _client = new Socket4Adapter(_plainSocketFactory.CreateSocket("localhost", _port)
         );
     _server = new Socket4Adapter(_serverSocket.Accept());
 }
 private void StartServerSocket()
 {
     try
     {
         _serverSocket = _socketFactory.CreateServerSocket(_port);
         _port         = _serverSocket.GetLocalPort();
     }
     catch (IOException e)
     {
         throw new Db4oIOException(e);
     }
     _serverSocket.SetSoTimeout(_serverConfig.TimeoutServerSocket);
 }
 private void CloseServerSocket()
 {
     try
     {
         if (_serverSocket != null)
         {
             _serverSocket.Close();
         }
     }
     catch (Exception)
     {
     }
     _serverSocket = null;
 }
Beispiel #5
0
        public void TestClientCertificateValidation()
        {
            ISocket4Factory sslSocketFactory = new SslSocketFactory(new StandardSocket4Factory(), ServerCertificate());
            IServerSocket4  serverSocket     = sslSocketFactory.CreateServerSocket(0);

            ThreadPool.QueueUserWorkItem(delegate
            {
                serverSocket.Accept();
            });

            SslSocketFactory clientSocketFactory = new SslSocketFactory(new StandardSocket4Factory(), delegate { return(false); });

            Assert.Expect(typeof(AuthenticationException), delegate
            {
                clientSocketFactory.CreateSocket("localhost", serverSocket.GetLocalPort());
            });
        }
Beispiel #6
0
        public void Test()
        {
            ISocket4Factory sslSocketFactory = new SslSocketFactory(new StandardSocket4Factory(), ServerCertificate());
            IServerSocket4  serverSocket     = sslSocketFactory.CreateServerSocket(0);

            PassThroughSocketFactory clientEncryptedContentsSocketFactory = NewPassThroughSocketFactory();
            PassThroughSocketFactory clientPassThroughSocketFactory       = new PassThroughSocketFactory(new SslSocketFactory(clientEncryptedContentsSocketFactory, ValidateServerCertificate));

            Thread clientThread = StartClient(serverSocket.GetLocalPort(), clientPassThroughSocketFactory);

            string msg = ReadString(serverSocket.Accept());

            Assert.AreEqual(Message, msg);
            AssertAreNotEqual(clientEncryptedContentsSocketFactory.LastClient.Written, clientPassThroughSocketFactory.LastClient.Written);

            clientThread.Join();
        }
Beispiel #7
0
        private void AssertTimeoutBehavior(Thread serverTrigger, int serverTimeout, ISocket4Factory clientSocketFactory)
        {
            ISocket4Factory sslSocketFactory = new SslSocketFactory(new StandardSocket4Factory(), ServerCertificate());
            IServerSocket4  serverSocket     = sslSocketFactory.CreateServerSocket(0);

            serverSocket.SetSoTimeout(serverTimeout);

            serverTrigger.IsBackground = true;
            serverTrigger.Start(serverSocket);

            ISocket4 clientSocket = clientSocketFactory.CreateSocket("localhost", serverSocket.GetLocalPort());

            if (!serverTrigger.Join(MinutesToMiliseconds(2)))
            {
                serverTrigger.Abort();
                Assert.Fail("Server thread should have timedout.");
            }
        }
 public MonitoredServerSocket4(IServerSocket4 serverSocket) : base(serverSocket)
 {
     _serverSocket = serverSocket;
 }
		public CountingServerSocket4(IServerSocket4 serverSocket)
		{
			_serverSocket = serverSocket;
		}
		private void CloseServerSocket()
		{
			try
			{
				if (_serverSocket != null)
				{
					_serverSocket.Close();
				}
			}
			catch (Exception)
			{
			}
			_serverSocket = null;
		}
		private void StartServerSocket()
		{
			try
			{
				_serverSocket = _socketFactory.CreateServerSocket(_port);
				_port = _serverSocket.GetLocalPort();
			}
			catch (IOException e)
			{
				throw new Db4oIOException(e);
			}
			_serverSocket.SetSoTimeout(_serverConfig.TimeoutServerSocket);
		}
 public CountingServerSocket4(IServerSocket4 serverSocket)
 {
     _serverSocket = serverSocket;
 }
Beispiel #13
0
 public ServerSslSocket(IServerSocket4 socket, X509Certificate2 certificate) : base(socket)
 {
     _certificate = certificate;
 }
Beispiel #14
0
 public ServerSocket4Decorator(IServerSocket4 serverSocket)
 {
     _serverSocket = serverSocket;
 }
Beispiel #15
0
 public ServerSocket4Decorator(IServerSocket4 serverSocket)
 {
     _serverSocket = serverSocket;
 }
Beispiel #16
0
 public ServerSslSocket(IServerSocket4 socket, X509Certificate2 certificate) : base(socket)
 {
     _certificate = certificate;
 }
		public MonitoredServerSocket4(IServerSocket4 serverSocket) : base(serverSocket)
		{
			_serverSocket = serverSocket;
		}
        public IServerSocket4 CreateServerSocket(int port)
        {
            IServerSocket4 serverSocket = _delegating.CreateServerSocket(port);

            return(new ServerSslSocket(serverSocket, _certificate));
        }