Skip to content
Snippets Groups Projects
Unverified Commit ddd7d8bf authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files

Add parseNameIdPolicy method

parent 4b98bc03
No related branches found
No related tags found
No related merge requests found
...@@ -279,4 +279,38 @@ class Metadata ...@@ -279,4 +279,38 @@ class Metadata
\SimpleSAML\Logger::popErrorMask(); \SimpleSAML\Logger::popErrorMask();
return $hidden === true; return $hidden === true;
} }
/**
* This method parses the different possible values of the NameIDPolicy metadata configuration.
*
* @param mixed $nameIdPolicy
*
* @return null|array
*/
public static function parseNameIdPolicy($nameIdPolicy)
{
$policy = null;
if (is_string($nameIdPolicy)) {
// handle old configurations where 'NameIDPolicy' was used to specify just the format
$policy = array('Format' => $nameIdPolicy);
} elseif (is_array($nameIdPolicy)) {
// handle current configurations specifying an array in the NameIDPolicy config option
$nameIdPolicy_cf = SimpleSAML_Configuration::loadFromArray($nameIdPolicy);
$policy = array(
'Format' => $nameIdPolicy_cf->getString('Format', \SAML2\Constants::NAMEID_TRANSIENT),
'AllowCreate' => $nameIdPolicy_cf->getBoolean('AllowCreate', true),
);
$spNameQualifier = $nameIdPolicy_cf->getString('SPNameQualifier', false);
if ($spNameQualifier !== false) {
$policy['SPNameQualifier'] = $spNameQualifier;
}
} elseif ($nameIdPolicy === null) {
// when NameIDPolicy is unset or set to null, default to transient as before
$policy = array('Format' => \SAML2\Constants::NAMEID_TRANSIENT);
}
return $policy;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment