Ejemplo n.º 1
0
        /// <summary>
        /// Raises <b>Authenticate</b> event.
        /// </summary>
        /// <param name="authorizationID">Authorization ID.</param>
        /// <param name="userName">User name.</param>
        /// <param name="password">Password.</param>
        /// <returns>Returns authentication result.</returns>
        private AUTH_e_Authenticate OnAuthenticate(string authorizationID, string userName, string password)
        {
            AUTH_e_Authenticate retVal = new AUTH_e_Authenticate(authorizationID, userName, password);

            if (this.Authenticate != null)
            {
                this.Authenticate(this, retVal);
            }

            return(retVal);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Continues authentication process.
        /// </summary>
        /// <param name="clientResponse">Client sent SASL response.</param>
        /// <returns>Retunrns challange response what must be sent to client or null if authentication has completed.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>clientResponse</b> is null reference.</exception>
        public override byte[] Continue(byte[] clientResponse)
        {
            if (clientResponse == null)
            {
                throw new ArgumentNullException("clientResponse");
            }

            /* RFC 4616.2. PLAIN SASL Mechanism.
             *  The mechanism consists of a single message, a string of [UTF-8]
             *  encoded [Unicode] characters, from the client to the server.  The
             *  client presents the authorization identity (identity to act as),
             *  followed by a NUL (U+0000) character, followed by the authentication
             *  identity (identity whose password will be used), followed by a NUL
             *  (U+0000) character, followed by the clear-text password.  As with
             *  other SASL mechanisms, the client does not provide an authorization
             *  identity when it wishes the server to derive an identity from the
             *  credentials and use that as the authorization identity.
             *
             *  message   = [authzid] UTF8NUL authcid UTF8NUL passwd
             *
             *  Example:
             *      C: a002 AUTHENTICATE "PLAIN"
             *      S: + ""
             *      C: {21}
             *      C: <NUL>tim<NUL>tanstaaftanstaaf
             *      S: a002 OK "Authenticated"
             */

            if (clientResponse.Length == 0)
            {
                return(new byte[0]);
            }
            // Parse response
            else
            {
                string[] authzid_authcid_passwd = Encoding.UTF8.GetString(clientResponse).Split('\0');
                if (authzid_authcid_passwd.Length == 3 && !string.IsNullOrEmpty(authzid_authcid_passwd[1]))
                {
                    m_UserName = authzid_authcid_passwd[1];
                    AUTH_e_Authenticate result = OnAuthenticate(authzid_authcid_passwd[0], authzid_authcid_passwd[1], authzid_authcid_passwd[2]);
                    m_IsAuthenticated = result.IsAuthenticated;
                }

                m_IsCompleted = true;
            }

            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Continues authentication process.
        /// </summary>
        /// <param name="clientResponse">Client sent SASL response.</param>
        /// <returns>Retunrns challange response what must be sent to client or null if authentication has completed.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>clientResponse</b> is null reference.</exception>
        public override byte[] Continue(byte[] clientResponse)
        {
            if (clientResponse == null)
            {
                throw new ArgumentNullException("clientResponse");
            }

            /* RFC none.
             *  S: "Username:"******"Password:"******"UserName:"******"Password:"******"", m_UserName, m_Password);
                m_IsAuthenticated = result.IsAuthenticated;
                m_IsCompleted     = true;
            }

            return(null);
        }