コード例 #1
0
        /// <summary>
        /// </summary>
        /// <param name="e"> </param>
        public override void Parse(Node e)
        {
            if (e.GetType() == typeof(Challenge))
            {
                var c = e as Challenge;

                var step1 = new Step1(c.TextBase64);
                if (step1.Rspauth == null)
                {
                    // response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9ImduYXVjayIscmVhbG09IiIsbm9uY2U9IjM4MDQzMjI1MSIsY25vbmNlPSIxNDE4N2MxMDUyODk3N2RiMjZjOWJhNDE2ZDgwNDI4MSIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9qYWJiZXIucnUiLGNoYXJzZXQ9dXRmLTgscmVzcG9uc2U9NDcwMTI5NDU4Y2EwOGVjYjhhYTIxY2UzMDhhM2U5Nzc
                    var s2 = new Step2(step1, base.Username, base.Password, base.Server);
                    var r  = new Response(s2.ToString());
                    //base.XmppClientConnection.Send(r);
                }
                else
                {
                    // SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
                    //base.XmppClientConnection.Send(new Response());
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// </summary>
        /// <param name="e"> </param>
        public override void Parse(Node e)
        {
            if (e.GetType() == typeof (Challenge))
            {
                var c = e as Challenge;

                var step1 = new Step1(c.TextBase64);
                if (step1.Rspauth == null)
                {
                    // response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9ImduYXVjayIscmVhbG09IiIsbm9uY2U9IjM4MDQzMjI1MSIsY25vbmNlPSIxNDE4N2MxMDUyODk3N2RiMjZjOWJhNDE2ZDgwNDI4MSIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9qYWJiZXIucnUiLGNoYXJzZXQ9dXRmLTgscmVzcG9uc2U9NDcwMTI5NDU4Y2EwOGVjYjhhYTIxY2UzMDhhM2U5Nzc
                    var s2 = new Step2(step1, base.Username, base.Password, base.Server);
                    var r = new Response(s2.ToString());
                    //base.XmppClientConnection.Send(r);
                }
                else
                {
                    // SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
                    //base.XmppClientConnection.Send(new Response());
                }
            }
        }
コード例 #3
0
        private Challenge ProcessStep1(XmppStream stream, Response response, XmppHandlerContext ctx)
        {
            var step = new Step2(response.TextBase64);
            var userName = step.Username;
            var user = ctx.UserManager.GetUser(new Jid(userName, stream.Domain, null));

            log.DebugFormat("User {0} {1}. Realm={2}", userName, user == null ? "not found" : user.ToString(), step.Realm);

            if (user != null && string.Compare(stream.Domain, step.Realm, StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (step.Authorize(userName, user.Password))
                {
                    log.DebugFormat("User authorized");
                    lock (authData)
                    {
                        authData[stream.Id].UserName = userName;
                    }
                    var challenge = new Challenge();
                    challenge.TextBase64 = string.Format("rspauth={0}", step.CalculateResponse(userName, user.Password, string.Empty));
                    return challenge;
                }
                else
                {
                    log.DebugFormat("User not authorized");
                }
            }
            return null;
        }