Esempio n. 1
0
        /// <summary>
        /// Performs the authentication using the Jabber mechanism.
        /// </summary>
        public override void Authenticate()
        {
            this.RequestAuthInformation();

            // Do authentication
            JabberAuthQuery auth = new JabberAuthQuery();

            if (authInfo.UserName != null)
            {
                auth.UserName = this.Connection.UserId.UserName;
            }
            if (authInfo.Resource != null)
            {
                auth.Resource = this.Connection.UserId.ResourceName;
            }
            if (authInfo.Digest != null)
            {
                auth.Digest = this.GenerateDigest(this.Connection.UserPassword);
            }
            else if (authInfo.Password != null)
            {
                auth.Password = this.Connection.UserPassword;
            }

            IQ iq = new IQ();

            iq.Type = IQType.Set;
            iq.ID   = XmppIdentifierGenerator.Generate();

            iq.Items.Add(auth);

            this.PendingMessages.Add(iq.ID);

            this.Connection.Send(iq);
        }
        /// <summary>
        /// Performs the authentication using the Jabber mechanism.
        /// </summary>
        public override void Authenticate()
        {
            this.RequestAuthInformation();

            // Do authentication
            JabberAuthQuery auth = new JabberAuthQuery();

            if (authInfo.UserName != null)
            {
                auth.UserName = this.Connection.UserId.UserName;
            }
            if (authInfo.Resource != null)
            {
                auth.Resource = this.Connection.UserId.ResourceName;
            }
            if (authInfo.Digest != null)
            {
                auth.Digest = this.GenerateDigest(this.Connection.UserPassword);
            }
            else if (authInfo.Password != null)
            {
                auth.Password = this.Connection.UserPassword;
            }

            IQ iq	= new IQ();
            iq.Type	= IQType.Set;
            iq.ID   = XmppIdentifierGenerator.Generate();

            iq.Items.Add(auth);

            this.PendingMessages.Add(iq.ID);

            this.Connection.Send(iq);
        }
Esempio n. 3
0
        private void RequestAuthInformation()
        {
            JabberAuthQuery auth = new JabberAuthQuery();
            IQ request           = new IQ();

            auth.UserName = this.Connection.UserId.UserName;
            request.To    = this.Connection.Server;
            request.Type  = IQType.Get;
            request.ID    = XmppIdentifierGenerator.Generate();

            request.Items.Add(auth);

            this.Connection.Send(request);

            // Wait for Response. It will be received in async mode
            this.authInfoEvent.WaitOne();
        }
Esempio n. 4
0
        /// <summary>
        /// Called when an unhandled message is received
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="T:Framework.Net.Xmpp.Core.XmppUnhandledMessageEventArgs"/> instance containing the event data.</param>
        protected override void OnUnhandledMessage(object sender, XmppUnhandledMessageEventArgs e)
        {
            if (e.StanzaInstance is IQ)
            {
                IQ response = (IQ)e.StanzaInstance;

                if (this.PendingMessages.Contains(response.ID))
                {
                    this.PendingMessages.Remove(response.ID);

                    if (this.authInfo == null)
                    {
                        // Response to teh Authentication Information Request
                        this.authInfo = (JabberAuthQuery)response.Items[0];
                        this.authInfoEvent.Set();
                    }
                }
            }
        }
        private void RequestAuthInformation()
        {
            JabberAuthQuery auth    = new JabberAuthQuery();
            IQ              request	= new IQ();

            auth.UserName   = this.Connection.UserId.UserName;
            request.To		= this.Connection.Server;
            request.Type	= IQType.Get;
            request.ID      = XmppIdentifierGenerator.Generate();

            request.Items.Add(auth);

            this.Connection.Send(request);

            // Wait for Response. It will be received in async mode
            this.authInfoEvent.WaitOne();
        }
        /// <summary>
        /// Called when an unhandled message is received
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="T:Framework.Net.Xmpp.Core.XmppUnhandledMessageEventArgs"/> instance containing the event data.</param>
        protected override void OnUnhandledMessage(object sender, XmppUnhandledMessageEventArgs e)
        {
            if (e.StanzaInstance is IQ)
            {
                IQ response = (IQ)e.StanzaInstance;

                if (this.PendingMessages.Contains(response.ID))
                {
                    this.PendingMessages.Remove(response.ID);

                    if (this.authInfo == null)
                    {
                        // Response to teh Authentication Information Request
                        this.authInfo = (JabberAuthQuery)response.Items[0];
                        this.authInfoEvent.Set();
                    }
                }
            }
        }