Example #1
1
        bool AcceptClient(UnixSocket csock, out ServerConnection conn)
        {
            //TODO: use the right abstraction here, probably using the Server class
            UnixNativeTransport transport = new UnixNativeTransport();
            //client.Client.Blocking = true;
            transport.socket = csock;
            transport.SocketHandle = (long)csock.Handle;
            transport.Stream = new UnixStream(csock);
            //Connection conn = new Connection (transport);
            //Connection conn = new ServerConnection (transport);
            //ServerConnection conn = new ServerConnection (transport);
            conn = new ServerConnection(transport);
            conn.Server = this;
            conn.Id = Id;

            if (conn.Transport.Stream.ReadByte() != 0)
                return false;

            conn.isConnected = true;

            SaslPeer remote = new SaslPeer();
            remote.stream = transport.Stream;
            SaslServer local = new SaslServer();
            local.stream = transport.Stream;
            local.Guid = Id;

            local.Peer = remote;
            remote.Peer = local;

            bool success = local.Authenticate();

            Console.WriteLine("Success? " + success);

            if (!success)
                return false;

            conn.UserId = ((SaslServer)local).uid;

            conn.isAuthenticated = true;

            return true;
        }
Example #2
0
        /// <summary>
        /// Constructs a SASLInputStream from an InputStream and a SaslClient <br />
        /// Note: if the specified InputStream or SaslClient is null, a
        /// NullPointerException may be thrown later when they are used.
        /// </summary>
        /// <param name="inStream">the InputStream to be processed</param>
        /// <param name="saslClient">an initialized SaslClient object</param>
        public SaslInputStream(InputStream inStream, SaslClient saslClient)
        {
            this.inStream   = new DataInputStream(inStream);
            this.saslServer = null;
            this.saslClient = saslClient;
            string qop = (string)saslClient.GetNegotiatedProperty(Javax.Security.Sasl.Sasl.Qop
                                                                  );

            this.useWrap = qop != null && !Runtime.EqualsIgnoreCase("auth", qop);
        }
Example #3
0
        public void AuthSelf()
        {
            SaslServer server = new SaslServer();
            SaslClient client = new SaslClient();

            server.Peer = client;
            client.Peer = server;

            client.Identity = "1000";
            server.Guid     = UUID.Generate();

            Assert.IsTrue(client.AuthenticateSelf());
            Assert.AreEqual(server.Guid, client.ActualId);
        }
		public void AuthSelf ()
		{
			SaslServer server = new SaslServer ();
			SaslClient client = new SaslClient ();

			server.Peer = client;
			client.Peer = server;

			client.Identity = "1000";
			server.Guid = UUID.Generate ();

			Assert.IsTrue (client.AuthenticateSelf ());
			Assert.AreEqual (server.Guid, client.ActualId);
		}
Example #5
0
        bool AcceptClient(UnixSocket csock, out ServerConnection conn)
        {
            //TODO: use the right abstraction here, probably using the Server class
            UnixNativeTransport transport = new UnixNativeTransport();

            //client.Client.Blocking = true;
            transport.socket       = csock;
            transport.SocketHandle = (long)csock.Handle;
            transport.Stream       = new UnixStream(csock);
            //Connection conn = new Connection (transport);
            //Connection conn = new ServerConnection (transport);
            //ServerConnection conn = new ServerConnection (transport);
            conn        = new ServerConnection(transport);
            conn.Server = this;
            //conn.Id = Id;

            if (conn.Transport.Stream.ReadByte() != 0)
            {
                return(false);
            }

            //conn.isConnected = true;

            SaslPeer remote = new SaslPeer();

            remote.stream = transport.Stream;
            SaslServer local = new SaslServer();

            local.stream = transport.Stream;
            local.Guid   = Id;

            local.Peer  = remote;
            remote.Peer = local;

            bool success = local.Authenticate();

            Console.WriteLine("Success? " + success);

            if (!success)
            {
                return(false);
            }

            conn.UserId = ((SaslServer)local).uid;

            //conn.isAuthenticated = true;

            return(true);
        }
Example #6
0
        bool AcceptClient(PipeStream client, out ServerConnection conn)
        {
            PipeTransport transport = new PipeTransport();

            //client.Client.Blocking = true;
            //transport.SocketHandle = (long)client.Client.Handle;
            transport.Stream = client;
            conn             = new ServerConnection(transport);
            conn.Server      = this;
            conn.Id          = Id;

            if (conn.Transport.Stream.ReadByte() != 0)
            {
                return(false);
            }

            conn.isConnected = true;

            SaslPeer remote = new SaslPeer();

            remote.stream = transport.Stream;
            SaslServer local = new SaslServer();

            local.stream = transport.Stream;
            local.Guid   = Id;

            local.Peer  = remote;
            remote.Peer = local;

            bool success = local.Authenticate();

            //bool success = true;

            Console.WriteLine("Success? " + success);

            if (!success)
            {
                return(false);
            }

            conn.UserId = ((SaslServer)local).uid;

            conn.isAuthenticated = true;

            return(true);
        }
Example #7
0
        /// <summary>
        /// Constructs a SASLOutputStream from an OutputStream and a SaslClient <br />
        /// Note: if the specified OutputStream or SaslClient is null, a
        /// NullPointerException may be thrown later when they are used.
        /// </summary>
        /// <param name="outStream">the OutputStream to be processed</param>
        /// <param name="saslClient">an initialized SaslClient object</param>
        public SaslOutputStream(OutputStream outStream, SaslClient saslClient)
        {
            this.saslServer = null;
            this.saslClient = saslClient;
            string qop = (string)saslClient.GetNegotiatedProperty(Javax.Security.Sasl.Sasl.Qop
                                                                  );

            this.useWrap = qop != null && !Runtime.EqualsIgnoreCase("auth", qop);
            if (useWrap)
            {
                this.outStream = new BufferedOutputStream(outStream, 64 * 1024);
            }
            else
            {
                this.outStream = outStream;
            }
        }
Example #8
0
        /// <summary>
        /// Constructs a SASLOutputStream from an OutputStream and a SaslServer <br />
        /// Note: if the specified OutputStream or SaslServer is null, a
        /// NullPointerException may be thrown later when they are used.
        /// </summary>
        /// <param name="outStream">the OutputStream to be processed</param>
        /// <param name="saslServer">an initialized SaslServer object</param>
        public SaslOutputStream(OutputStream outStream, SaslServer saslServer)
        {
            // processed data ready to be written out
            // buffer holding one byte of incoming data
            this.saslServer = saslServer;
            this.saslClient = null;
            string qop = (string)saslServer.GetNegotiatedProperty(Javax.Security.Sasl.Sasl.Qop
                                                                  );

            this.useWrap = qop != null && !Runtime.EqualsIgnoreCase("auth", qop);
            if (useWrap)
            {
                this.outStream = new BufferedOutputStream(outStream, 64 * 1024);
            }
            else
            {
                this.outStream = outStream;
            }
        }
Example #9
0
            /// <exception cref="Javax.Security.Sasl.SaslException"/>
            public virtual SaslServer CreateSaslServer(string mechanism, string protocol, string
                                                       serverName, IDictionary <string, object> props, CallbackHandler cbh)
            {
                SaslServer saslServer = null;
                IList <SaslServerFactory> factories = factoryCache[mechanism];

                if (factories != null)
                {
                    foreach (SaslServerFactory factory in factories)
                    {
                        saslServer = factory.CreateSaslServer(mechanism, protocol, serverName, props, cbh
                                                              );
                        if (saslServer != null)
                        {
                            break;
                        }
                    }
                }
                return(saslServer);
            }
Example #10
0
        bool AcceptClient(PipeStream client, out ServerConnection conn)
        {
            PipeTransport transport = new PipeTransport ();
            //client.Client.Blocking = true;
            //transport.SocketHandle = (long)client.Client.Handle;
            transport.Stream = client;
            conn = new ServerConnection (transport);
            conn.Server = this;
            conn.Id = Id;

            if (conn.Transport.Stream.ReadByte () != 0)
                return false;

            conn.isConnected = true;

            SaslPeer remote = new SaslPeer ();
            remote.stream = transport.Stream;
            SaslServer local = new SaslServer ();
            local.stream = transport.Stream;
            local.Guid = Id;

            local.Peer = remote;
            remote.Peer = local;

            bool success = local.Authenticate ();
            //bool success = true;

            Console.WriteLine ("Success? " + success);

            if (!success)
                return false;

            conn.UserId = ((SaslServer)local).uid;

            conn.isAuthenticated = true;

            return true;
        }
Example #11
0
 /// <summary>Private constructor wrapping a SaslClient.</summary>
 /// <param name="saslClient">to wrap</param>
 private SaslParticipant(SaslClient saslClient)
 {
     this.saslServer = null;
     this.saslClient = saslClient;
 }
Example #12
0
 /// <summary>Private constructor wrapping a SaslServer.</summary>
 /// <param name="saslServer">to wrap</param>
 private SaslParticipant(SaslServer saslServer)
 {
     this.saslServer = saslServer;
     this.saslClient = null;
 }