SimpleSAML_Metadata_Signer::getMetadataSigningAlgorithm PHP Méthode

getMetadataSigningAlgorithm() private static méthode

This method will look for the 'metadata.sign.algorithm' key in the $entityMetadata array, or look for such a configuration option in the $config object.
private static getMetadataSigningAlgorithm ( SimpleSAML_Configuration $config, array $entityMetadata, string $type ) : array
$config SimpleSAML_Configuration The global configuration.
$entityMetadata array An array containing the metadata related to this entity.
$type string A string describing the type of entity. E.g. 'SAML 2 IdP' or 'Shib 1.3 SP'.
Résultat array An array with two keys, 'algorithm' and 'digest', corresponding to the signature and digest algorithms to use, respectively.
    private static function getMetadataSigningAlgorithm($config, $entityMetadata, $type)
    {
        // configure the algorithm to use
        if (array_key_exists('metadata.sign.algorithm', $entityMetadata)) {
            if (!is_string($entityMetadata['metadata.sign.algorithm'])) {
                throw new \SimpleSAML\Error\CriticalConfigurationError("Invalid value for the 'metadata.sign.algorithm' configuration option for the " . $type . "'" . $entityMetadata['entityid'] . "'. This option has restricted values");
            }
            $alg = $entityMetadata['metadata.sign.algorithm'];
        } else {
            $alg = $config->getString('metadata.sign.algorithm', XMLSecurityKey::RSA_SHA1);
        }
        $supported_algs = array(XMLSecurityKey::RSA_SHA1, XMLSecurityKey::RSA_SHA256, XMLSecurityKey::RSA_SHA384, XMLSecurityKey::RSA_SHA512);
        if (!in_array($alg, $supported_algs)) {
            throw new \SimpleSAML\Error\CriticalConfigurationError("Unknown signature algorithm '{$alg}'");
        }
        switch ($alg) {
            case XMLSecurityKey::RSA_SHA256:
                $digest = XMLSecurityDSig::SHA256;
                break;
            case XMLSecurityKey::RSA_SHA384:
                $digest = XMLSecurityDSig::SHA384;
                break;
            case XMLSecurityKey::RSA_SHA512:
                $digest = XMLSecurityDSig::SHA512;
                break;
            default:
                $digest = XMLSecurityDSig::SHA1;
        }
        return array('algorithm' => $alg, 'digest' => $digest);
    }