SimpleSAML_Metadata_SAMLParser::parseKeyDescriptor PHP Method

parseKeyDescriptor() private static method

The associative array for a key can contain: - 'encryption': Indicates whether this key can be used for encryption. - 'signing': Indicates whether this key can be used for signing. - 'type: The type of the key. 'X509Certificate' is the only key type we support. - 'X509Certificate': The contents of the first X509Certificate element (if the type is 'X509Certificate ').
private static parseKeyDescriptor ( SAML2\XML\md\KeyDescriptor $kd ) : array | null
$kd SAML2\XML\md\KeyDescriptor The KeyDescriptor element.
return array | null An associative array describing the key, or null if this is an unsupported key.
    private static function parseKeyDescriptor(\SAML2\XML\md\KeyDescriptor $kd)
    {
        $r = array();
        if ($kd->use === 'encryption') {
            $r['encryption'] = true;
            $r['signing'] = false;
        } elseif ($kd->use === 'signing') {
            $r['encryption'] = false;
            $r['signing'] = true;
        } else {
            $r['encryption'] = true;
            $r['signing'] = true;
        }
        $keyInfo = $kd->KeyInfo;
        foreach ($keyInfo->info as $i) {
            if ($i instanceof \SAML2\XML\ds\X509Data) {
                foreach ($i->data as $d) {
                    if ($d instanceof \SAML2\XML\ds\X509Certificate) {
                        $r['type'] = 'X509Certificate';
                        $r['X509Certificate'] = $d->certificate;
                        return $r;
                    }
                }
            }
        }
        return null;
    }