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 {
$base64 = isset($idpmd['base64attributes']) ? $idpmd['base64attributes'] : false;
$encodedattributes = '';
foreach ($attributes AS $name => $value) {
$encodedattributes .= $this->enc_attribute($name, $value[0], $base64);
foreach ($attributes AS $name => $values) {
$encodedattributes .= self::enc_attribute($name, $values, $base64);
}
$attributestatement = '<saml:AttributeStatement>' . $encodedattributes . '</saml:AttributeStatement>';
......@@ -516,11 +516,39 @@ Version="2.0">
}
private function enc_attribute($name,$value, $base64 = false) {
return '<saml:Attribute Name="' . $name. '">
<saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
>' . ($base64 ? base64_encode($value) : htmlspecialchars($value) ) . '</saml:AttributeValue>
</saml:Attribute>';
/* This function converts an array of attribute values into an
* encoded saml:Attribute element which should go into the
* AuthnResponse. The data can optionally be base64 encoded.
*
* 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