示例#1
0
文件: Step2.cs 项目: don59/agsXmpp
		/// <summary>
		/// builds a step2 message reply to the given step1 message
		/// </summary>
		/// <param name="step1"></param>
		public Step2(Step1 step1, string username, string password, string server)
		{
            this.Nonce		= step1.Nonce;
            
            // fixed for SASL n amessage servers (jabberd 1.x)
            if (SupportsAuth(step1.Qop))
                this.Qop        = "auth";
			
            this.Realm		= step1.Realm;
			this.Charset	= step1.Charset;
			this.Algorithm	= step1.Algorithm;

			this.Username	= username;
			this.Password	= password;
			this.Server		= server;

			GenerateCnonce();
			GenerateNc();
			GenerateDigestUri();
			GenerateResponse();
		}
		public override void Parse(Node e)
		{
			if (e is protocol.sasl.Challenge)
			{
				protocol.sasl.Challenge c = e as protocol.sasl.Challenge;
				
				Step1 step1 = new Step1(c.TextBase64);
				if (step1.Rspauth == null)
				{
					//response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9ImduYXVjayIscmVhbG09IiIsbm9uY2U9IjM4MDQzMjI1MSIsY25vbmNlPSIxNDE4N2MxMDUyODk3N2RiMjZjOWJhNDE2ZDgwNDI4MSIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9qYWJiZXIucnUiLGNoYXJzZXQ9dXRmLTgscmVzcG9uc2U9NDcwMTI5NDU4Y2EwOGVjYjhhYTIxY2UzMDhhM2U5Nzc
					Step2 s2 = new Step2(step1, base.Username, base.Password, base.Server);
					protocol.sasl.Response r = new agsXMPP.protocol.sasl.Response(s2.ToString());
                    base.XmppClientConnection.Send(r);
				}
				else
				{
					// SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
                    base.XmppClientConnection.Send(new protocol.sasl.Response());
				}						
			}
		}
        public override void Parse(Node e)
        {
            if (e is protocol.sasl.Challenge)
            {
                protocol.sasl.Challenge c = e as protocol.sasl.Challenge;

                Step1 step1 = new Step1(c.TextBase64);
                if (step1.Rspauth == null)
                {
                    //response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9ImduYXVjayIscmVhbG09IiIsbm9uY2U9IjM4MDQzMjI1MSIsY25vbmNlPSIxNDE4N2MxMDUyODk3N2RiMjZjOWJhNDE2ZDgwNDI4MSIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9qYWJiZXIucnUiLGNoYXJzZXQ9dXRmLTgscmVzcG9uc2U9NDcwMTI5NDU4Y2EwOGVjYjhhYTIxY2UzMDhhM2U5Nzc
                    Step2 s2 = new Step2(step1, base.Username, base.Password, base.Server);
                    protocol.sasl.Response r = new agsXMPP.protocol.sasl.Response(s2.ToString());
                    base.XmppClientConnection.Send(r);
                }
                else
                {
                    // SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
                    base.XmppClientConnection.Send(new protocol.sasl.Response());
                }
            }
        }
示例#4
0
        /// <summary>
        ///     builds a step2 message reply to the given step1 message
        /// </summary>
        /// <param name="step1"></param>
        public Step2(Step1 step1, string username, string password, string server)
        {
            Nonce = step1.Nonce;

            // fixed for SASL n amessage servers (jabberd 1.x)
            if (SupportsAuth(step1.Qop))
            {
                Qop = "auth";
            }

            Realm     = step1.Realm;
            Charset   = step1.Charset;
            Algorithm = step1.Algorithm;

            Username = username;
            Password = password;
            Server   = server;

            GenerateCnonce();
            GenerateNc();
            GenerateDigestUri();
            GenerateResponse();
        }