Skip to content
Snippets Groups Projects
Commit fa915600 authored by Olav Morken's avatar Olav Morken
Browse files

Upgrade NameId array format.

Change all users of the nameId arrays to use 'Value' instead of
'value'. 'value' was the old name, but this is changed to 'Value' in
order to be consistent with other attributes.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1654 44740490-163a-0410-bde0-09ae8108e29a
parent 7c4723b4
No related branches found
No related tags found
No related merge requests found
...@@ -318,6 +318,19 @@ class SimpleSAML_Session { ...@@ -318,6 +318,19 @@ class SimpleSAML_Session {
$this->nameid = $nameid; $this->nameid = $nameid;
} }
public function getNameID() { public function getNameID() {
if (array_key_exists('value', $this->nameid)) {
/*
* This session was saved by an old version of simpleSAMLphp.
* Convert to the new NameId format.
*
* TODO: Remove this conversion once every session uses the new format.
*/
$this->nameid['Value'] = $this->nameid['value'];
unset($this->nameid['value']);
$this->dirty = TRUE;
}
return $this->nameid; return $this->nameid;
} }
...@@ -369,7 +382,19 @@ class SimpleSAML_Session { ...@@ -369,7 +382,19 @@ class SimpleSAML_Session {
return NULL; return NULL;
} }
return $this->sessionNameId[$entityType][$entityId]; $nameId = $this->sessionNameId[$entityType][$entityId];
if (array_key_exists('value', $nameId)) {
/*
* This session was saved by an old version of simpleSAMLphp.
* Convert to the new NameId format.
*
* TODO: Remove this conversion once every session should use the new format.
*/
$nameId['Value'] = $nameId['value'];
unset($nameId['value']);
}
return $nameId;
} }
......
...@@ -227,7 +227,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse { ...@@ -227,7 +227,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
$query = '/mysamlp:Response/mysaml:Assertion/mysaml:AuthenticationStatement/mysaml:Subject/mysaml:NameIdentifier'; $query = '/mysamlp:Response/mysaml:Assertion/mysaml:AuthenticationStatement/mysaml:Subject/mysaml:NameIdentifier';
$nodelist = $xPath->query($query); $nodelist = $xPath->query($query);
if ($node = $nodelist->item(0)) { if ($node = $nodelist->item(0)) {
$nameID["value"] = $node->nodeValue; $nameID["Value"] = $node->nodeValue;
$nameID["Format"] = $node->getAttribute('Format'); $nameID["Format"] = $node->getAttribute('Format');
//$nameID["NameQualifier"] = $node->getAttribute('NameQualifier'); //$nameID["NameQualifier"] = $node->getAttribute('NameQualifier');
} }
......
...@@ -248,7 +248,7 @@ if (!$session->isValid($authority) ) { ...@@ -248,7 +248,7 @@ if (!$session->isValid($authority) ) {
if (array_key_exists('RelayState', $requestcache)) $relayState = $requestcache['RelayState']; if (array_key_exists('RelayState', $requestcache)) $relayState = $requestcache['RelayState'];
$nameid = $session->getNameID(); $nameid = $session->getNameID();
$nameid = $nameid['value']; $nameid = $nameid['Value'];
$nameidattribute = $spmetadata->getValue('simplesaml.nameidattribute'); $nameidattribute = $spmetadata->getValue('simplesaml.nameidattribute');
if (isset($nameidattribute)) { if (isset($nameidattribute)) {
......
...@@ -244,6 +244,17 @@ class sspmod_saml2_Auth_Source_SP extends SimpleSAML_Auth_Source { ...@@ -244,6 +244,17 @@ class sspmod_saml2_Auth_Source_SP extends SimpleSAML_Auth_Source {
$nameId = $state[self::LOGOUT_NAMEID]; $nameId = $state[self::LOGOUT_NAMEID];
$sessionIndex = $state[self::LOGOUT_SESSIONINDEX]; $sessionIndex = $state[self::LOGOUT_SESSIONINDEX];
if (array_key_exists('value', $nameId)) {
/*
* This session was saved by an old version of simpleSAMLphp.
* Convert to the new NameId format.
*
* TODO: Remove this conversion once every session should use the new format.
*/
$nameId['Value'] = $nameId['value'];
unset($nameId['value']);
}
$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
$spMetadata = $metadata->getMetaDataConfig($this->getEntityId(), 'saml20-sp-hosted'); $spMetadata = $metadata->getMetaDataConfig($this->getEntityId(), 'saml20-sp-hosted');
$idpMetadata = $metadata->getMetaDataConfig($idp, 'saml20-idp-remote'); $idpMetadata = $metadata->getMetaDataConfig($idp, 'saml20-idp-remote');
......
...@@ -69,12 +69,7 @@ if (empty($defNameId)) { ...@@ -69,12 +69,7 @@ if (empty($defNameId)) {
$defNameId = array(); $defNameId = array();
} }
if (!array_key_exists('Value', $defNameId)) { if (!array_key_exists('Value', $defNameId)) {
if (array_key_exists('value', $defNameId)) { $defNameId['Value'] = SimpleSAML_Utilities::generateID();
/* For backwards compatibility. */
$defNameId['Value'] = $defNameId['value'];
} else {
$defNameId['Value'] = SimpleSAML_Utilities::generateID();
}
} }
if (!array_key_exists('Format', $defNameId)) { if (!array_key_exists('Format', $defNameId)) {
$defNameId['Format'] = SAML2_Const::NAMEID_TRANSIENT; $defNameId['Format'] = SAML2_Const::NAMEID_TRANSIENT;
......
...@@ -426,7 +426,6 @@ if($needAuth && !$isPassive) { ...@@ -426,7 +426,6 @@ if($needAuth && !$isPassive) {
$assertion->setInResponseTo($requestID); $assertion->setInResponseTo($requestID);
$nameId = $assertion->getNameId(); $nameId = $assertion->getNameId();
$nameId['value'] = $nameId['Value'];
$session->setSessionNameId('saml20-sp-remote', $spentityid, $nameId); $session->setSessionNameId('saml20-sp-remote', $spentityid, $nameId);
/* Maybe encrypt the assertion. */ /* Maybe encrypt the assertion. */
......
...@@ -234,10 +234,6 @@ if ($spEntityId) { ...@@ -234,10 +234,6 @@ if ($spEntityId) {
$nameId = $session->getNameID(); $nameId = $session->getNameID();
} }
/* Convert to new-style NameId format. */
$nameId['Value'] = $nameId['value'];
unset($nameId['value']);
$lr = sspmod_saml2_Message::buildLogoutRequest($idpMetadata, $spMetadata); $lr = sspmod_saml2_Message::buildLogoutRequest($idpMetadata, $spMetadata);
$lr->setSessionIndex($session->getSessionIndex()); $lr->setSessionIndex($session->getSessionIndex());
$lr->setNameId($nameId); $lr->setNameId($nameId);
......
...@@ -265,10 +265,6 @@ foreach ($listofsps AS $spentityid) { ...@@ -265,10 +265,6 @@ foreach ($listofsps AS $spentityid) {
$nameId = $session->getNameID(); $nameId = $session->getNameID();
} }
/* Convert to new-style NameId format. */
$nameId['Value'] = $nameId['value'];
unset($nameId['value']);
$spMetadata = $metadata->getMetaDataConfig($spentityid, 'saml20-sp-remote'); $spMetadata = $metadata->getMetaDataConfig($spentityid, 'saml20-sp-remote');
$name = $spMetadata->getValue('name', $spentityid); $name = $spMetadata->getValue('name', $spentityid);
......
...@@ -191,11 +191,6 @@ foreach ($listofsps AS $spentityid) { ...@@ -191,11 +191,6 @@ foreach ($listofsps AS $spentityid) {
$nameId = $session->getNameID(); $nameId = $session->getNameID();
} }
/* Convert to new-style NameId format. */
$nameId['Value'] = $nameId['value'];
unset($nameId['value']);
$spMetadata = $metadata->getMetaDataConfig($spentityid, 'saml20-sp-remote'); $spMetadata = $metadata->getMetaDataConfig($spentityid, 'saml20-sp-remote');
$name = $spMetadata->getValue('name', $spentityid); $name = $spMetadata->getValue('name', $spentityid);
......
...@@ -145,10 +145,7 @@ try { ...@@ -145,10 +145,7 @@ try {
SimpleSAML_Logger::stats('saml20-sp-SSO ' . $metadataHandler->getMetaDataCurrentEntityID() . ' ' . $idp . ' NA'); SimpleSAML_Logger::stats('saml20-sp-SSO ' . $metadataHandler->getMetaDataCurrentEntityID() . ' ' . $idp . ' NA');
/* Convert the NameId array to the old style. */
$nameId = $assertion->getNameId(); $nameId = $assertion->getNameId();
$nameId['value'] = $nameId['Value'];
unset($nameId['Value']);
/* Begin module attribute processing */ /* Begin module attribute processing */
......
...@@ -36,10 +36,7 @@ try { ...@@ -36,10 +36,7 @@ try {
$spEntityId = isset($_GET['spentityid']) ? $_GET['spentityid'] : $metadata->getMetaDataCurrentEntityID(); $spEntityId = isset($_GET['spentityid']) ? $_GET['spentityid'] : $metadata->getMetaDataCurrentEntityID();
$spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-hosted'); $spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-hosted');
/* Convert NameId to new style. */
$nameId = $session->getNameId(); $nameId = $session->getNameId();
$nameId['Value'] = $nameId['value'];
unset($nameId['value']);
$lr = sspmod_saml2_Message::buildLogoutRequest($spMetadata, $idpMetadata); $lr = sspmod_saml2_Message::buildLogoutRequest($spMetadata, $idpMetadata);
$lr->setNameId($nameId); $lr->setNameId($nameId);
......
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