Пример #1
0
        /// <summary>
        /// builds a step2 message reply to the given step1 message
        /// </summary>
        /// <param name="step1">The step1.</param>
        /// <param name="xmppClient">The xmppClient.</param>
        public Step2(Step1 step1, XmppClient xmppClient)
        {
            this.step1      = step1;
            this.xmppClient = xmppClient;

            this.step1.Nonce = step1.Nonce;

            GenerateCnonce();
            GenerateNc();
            GenerateDigestUri();
            GenerateResponse();
        }
        public async Task <XmppXElement> HandleChallenge(Challenge ch, XmppClient xmppClient, CancellationToken cancellationToken)
        {
            byte[] bytes = ch.Bytes;
            string s     = Encoding.ASCII.GetString(bytes, 0, bytes.Length);

            var step1 = new Step1(s);

            if (step1.Rspauth == null)
            {
                var s2 = new Step2(step1, xmppClient);

                string message = s2.GetMessage();
                byte[] b       = Encoding.UTF8.GetBytes(message);

                return(await xmppClient.SendAsync <Failure, Challenge, Success>(new Response { Bytes = b }, cancellationToken));
            }

            return(await xmppClient.SendAsync <Failure, Success>(new Response(), cancellationToken));
        }