public ISaslStep Transition(SaslConversation conversation, byte[] bytesReceivedFromServer)
            {
                byte[] bytesToSendToServer;
                try
                {
                    bytesToSendToServer = _context.Next(bytesReceivedFromServer);
                }
                catch (GssapiException ex)
                {
                    throw new MongoAuthenticationException(conversation.ConnectionId, "Unable to initialize security context", ex);
                }

                if (!_context.IsInitialized)
                {
                    return(new InitializeStep(_authorizationId, _context, bytesToSendToServer));
                }

                return(new NegotiateStep(_authorizationId, _context, bytesToSendToServer));
            }
            public FirstStep(string serviceName, string hostname, string realm, string username, SecureString password, SaslConversation conversation)
            {
                _authorizationId = username;

                try
                {
                    _context = SecurityContextFactory.InitializeSecurityContext(serviceName, hostname, realm, _authorizationId, password);
                    conversation.RegisterItemForDisposal(_context);
                    _bytesToSendToServer = _context.Next(null);
                }
                catch (GssapiException ex)
                {
                    if (password != null)
                    {
                        throw new MongoAuthenticationException(conversation.ConnectionId, "Unable to initialize security context. Ensure the username and password are correct.", ex);
                    }
                    else
                    {
                        throw new MongoAuthenticationException(conversation.ConnectionId, "Unable to initialize security context.", ex);
                    }
                }
            }