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

Added support for multivalued attributes in the IdP.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@90 44740490-163a-0410-bde0-09ae8108e29a
parent b0463e04
No related branches found
No related tags found
No related merge requests found
...@@ -366,8 +366,8 @@ class SimpleSAML_XML_SAML20_AuthnResponse extends SimpleSAML_XML_AuthnResponse { ...@@ -366,8 +366,8 @@ class SimpleSAML_XML_SAML20_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
$base64 = isset($idpmd['base64attributes']) ? $idpmd['base64attributes'] : false; $base64 = isset($idpmd['base64attributes']) ? $idpmd['base64attributes'] : false;
$encodedattributes = ''; $encodedattributes = '';
foreach ($attributes AS $name => $value) { foreach ($attributes AS $name => $values) {
$encodedattributes .= $this->enc_attribute($name, $value[0], $base64); $encodedattributes .= self::enc_attribute($name, $values, $base64);
} }
$attributestatement = '<saml:AttributeStatement>' . $encodedattributes . '</saml:AttributeStatement>'; $attributestatement = '<saml:AttributeStatement>' . $encodedattributes . '</saml:AttributeStatement>';
...@@ -516,11 +516,39 @@ Version="2.0"> ...@@ -516,11 +516,39 @@ Version="2.0">
} }
private function enc_attribute($name,$value, $base64 = false) { /* This function converts an array of attribute values into an
return '<saml:Attribute Name="' . $name. '"> * encoded saml:Attribute element which should go into the
<saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" * AuthnResponse. The data can optionally be base64 encoded.
>' . ($base64 ? base64_encode($value) : htmlspecialchars($value) ) . '</saml:AttributeValue> *
</saml:Attribute>'; * Parameters:
* $name Name of this attribute.
* $values Array with the values of this attribute.
* $base64 Enable base64 encoding of attribute values.
*
* Returns:
* String containing the encoded saml:attribute value for this
* attribute.
*/
private static function enc_attribute($name, $values, $base64 = false) {
assert(is_array($values));
$ret = '<saml:Attribute Name="' . $name . '">';
foreach($values as $value) {
if($base64) {
$text = base64_encode($value);
} else {
$text = htmlspecialchars($value);
}
$ret .= '<saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">' .
$text . '</saml:AttributeValue>';
}
$ret .= '</saml:Attribute>';
return $ret;
} }
......
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