XMPPStream::get_challenge_response PHP Method

get_challenge_response() public method

public get_challenge_response ( $decoded )
    public function get_challenge_response($decoded)
    {
        $response = array();
        $nc = '00000001';
        if (!isset($decoded['digest-uri'])) {
            $decoded['digest-uri'] = 'xmpp/' . $this->jid->domain;
        }
        $decoded['cnonce'] = base64_encode(JAXLUtil::get_nonce());
        if (isset($decoded['qop']) && $decoded['qop'] != 'auth' && strpos($decoded['qop'], 'auth') !== false) {
            $decoded['qop'] = 'auth';
        }
        $data = array_merge($decoded, array('nc' => $nc));
        $response = array('username' => $this->jid->node, 'response' => $this->encrypt_password($data, $this->jid->node, $this->pass), 'charset' => 'utf-8', 'nc' => $nc, 'qop' => 'auth');
        foreach (array('nonce', 'digest-uri', 'realm', 'cnonce') as $key) {
            if (isset($decoded[$key])) {
                $response[$key] = $decoded[$key];
            }
        }
        return base64_encode($this->implode_data($response));
    }