コード例 #1
0
        void Authenticate()
        {
            if (transport != null)
            {
                transport.WriteCred();
            }

            SaslClient auth = new SaslClient();

            auth.Identity    = transport.AuthString();
            auth.stream      = transport.Stream;
            auth.Peer        = new SaslPeer();
            auth.Peer.Peer   = auth;
            auth.Peer.stream = transport.Stream;

            if (!auth.Authenticate())
            {
                throw new Exception("Authentication failure");
            }

            if (Id != UUID.Zero)
            {
                if (auth.ActualId != Id)
                {
                    throw new Exception("Authentication failure: Unexpected GUID");
                }
            }

            if (Id == UUID.Zero)
            {
                Id = auth.ActualId;
            }

            isAuthenticated = true;
        }