Skip to content
Snippets Groups Projects
Commit 7bbf9fc7 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Use utility-method to parse NameIDPolicy

parent ddd7d8bf
No related branches found
No related tags found
No related merge requests found
...@@ -297,7 +297,7 @@ class Metadata ...@@ -297,7 +297,7 @@ class Metadata
$policy = array('Format' => $nameIdPolicy); $policy = array('Format' => $nameIdPolicy);
} elseif (is_array($nameIdPolicy)) { } elseif (is_array($nameIdPolicy)) {
// handle current configurations specifying an array in the NameIDPolicy config option // handle current configurations specifying an array in the NameIDPolicy config option
$nameIdPolicy_cf = SimpleSAML_Configuration::loadFromArray($nameIdPolicy); $nameIdPolicy_cf = \SimpleSAML_Configuration::loadFromArray($nameIdPolicy);
$policy = array( $policy = array(
'Format' => $nameIdPolicy_cf->getString('Format', \SAML2\Constants::NAMEID_TRANSIENT), 'Format' => $nameIdPolicy_cf->getString('Format', \SAML2\Constants::NAMEID_TRANSIENT),
'AllowCreate' => $nameIdPolicy_cf->getBoolean('AllowCreate', true), 'AllowCreate' => $nameIdPolicy_cf->getBoolean('AllowCreate', true),
......
...@@ -442,26 +442,7 @@ class sspmod_saml_Message ...@@ -442,26 +442,7 @@ class sspmod_saml_Message
$nameIdPolicy = $spMetadata->getValue('NameIDPolicy'); $nameIdPolicy = $spMetadata->getValue('NameIDPolicy');
} }
$policy = null; $policy = \SimpleSAML\Utils\Config\Metadata::parseNameIdPolicy($nameIdPolicy);
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);
}
if ($policy !== null) { if ($policy !== null) {
// either we have a policy set, or we used the transient default // either we have a policy set, or we used the transient default
$ar->setNameIdPolicy($policy); $ar->setNameIdPolicy($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