Exemple #1
0
        private void selectMechanism(ArrayList mechanisms)
        {
            string selected = null;

            foreach (string s in OFFERED_MECHANISMS)
            {
                foreach (string m in mechanisms)
                {
                    if (m.ToLowerInvariant().Equals(s))
                    {
                        selected = s;
                        break;
                    }
                }
                if (selected != null)
                {
                    break;
                }
            }
            XMPPAccount sCC = XMPP_CONNECTION.account;

            switch (selected)
            {
            case "scram-sha-256":
                selectedMechanism = new ScramSHA256SASLMechanism(sCC.user.localPart, sCC.user.password, this);
                break;

            case "scram-sha-1":
                selectedMechanism = new ScramSHA1SASLMechanism(sCC.user.localPart, sCC.user.password, this);
                break;

            case "plain":
                selectedMechanism = new PlainSASLMechanism(sCC.user.localPart, sCC.user.password, this);
                break;

            default:
                onSaslError("Failed to select authentication mechanism - \"" + selected + "\" is no supported mechanism!", SASLState.NO_VALID_MECHANISM);
                break;
            }
        }
        private void selectMechanism(ArrayList mechanisms)
        {
            string selected = null;

            foreach (string s in OFFERED_MECHANISMS)
            {
                foreach (string m in mechanisms)
                {
                    if (m.ToLower().Equals(s))
                    {
                        selected = s;
                        break;
                    }
                }
                if (selected != null)
                {
                    break;
                }
            }
            XMPPAccount sCC = XMPP_CONNECTION.account;

            switch (selected)
            {
            case "scram-sha-1":
                selectedMechanism = new ScramSHA1SASLMechanism(sCC.user.userId, sCC.user.userPassword);
                break;

            case "plain":
                selectedMechanism = new PlainSASLMechanism(sCC.user.userId, sCC.user.userPassword);
                break;

            default:
                state = SASLState.NO_VALID_MECHANISM;
                Logger.Error("Failed to select authentication mechanism. No supported mechanism available!");
                Task t = XMPP_CONNECTION.onMessageProcessorFailedAsync(new ConnectionError(ConnectionErrorCode.SASL_FAILED, "Failed to select authentication mechanism. No supported mechanism available!"), true);
                break;
            }
        }
Exemple #3
0
 //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
 #region --Misc Methods (Public)--
 public override void reset()
 {
     state             = SASLState.DISCONNECTED;
     selectedMechanism = null;
     startListeningForMessages();
 }