JAXL::handle_auth_mechs PHP Method

handle_auth_mechs() public method

public handle_auth_mechs ( $stanza, $mechanisms )
    public function handle_auth_mechs($stanza, $mechanisms)
    {
        if ($this->ev->exists('on_stream_features')) {
            return $this->ev->emit('on_stream_features', array($stanza));
        }
        // extract available mechanisms
        $mechs = array();
        if ($mechanisms) {
            foreach ($mechanisms->children as $mechanism) {
                $mechs[$mechanism->text] = true;
            }
        }
        $pref_auth = $this->cfg['auth_type'];
        // check if preferred auth type exists in available mechanisms
        if (isset($mechs[$pref_auth]) && $mechs[$pref_auth]) {
            JAXLLogger::debug("pref_auth " . $pref_auth . " exists");
        } else {
            JAXLLogger::debug("pref_auth " . $pref_auth . " doesn't exists");
            JAXLLogger::error("preferred auth type not supported, trying {$pref_auth}");
        }
        $this->send_auth_pkt($pref_auth, isset($this->jid) ? $this->jid->to_string() : null, $this->pass);
        if ($pref_auth == 'CRAM-MD5') {
            return "wait_for_cram_md5_response";
        } elseif ($pref_auth == 'SCRAM-SHA-1') {
            return "wait_for_scram_sha1_response";
        }
    }