From 0010ce04c3ae7aa2af5c70bbfcc856ddf595900d Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 17 Aug 2009 12:26:11 +0000 Subject: [PATCH] saml2_Message: Allow base64attributes and attributeencodigns to be specified on both src metadata and dst metadata. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1685 44740490-163a-0410-bde0-09ae8108e29a --- modules/saml2/lib/Message.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/saml2/lib/Message.php b/modules/saml2/lib/Message.php index 866d95f32..be6af3340 100644 --- a/modules/saml2/lib/Message.php +++ b/modules/saml2/lib/Message.php @@ -448,14 +448,25 @@ class sspmod_saml2_Message { private static function encodeAttributes(SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata, array $attributes) { - $base64Attributes = $dstMetadata->getBoolean('base64attributes', FALSE); + $base64Attributes = $dstMetadata->getBoolean('base64attributes', NULL); + if ($base64Attributes === NULL) { + $base64Attributes = $srcMetadata->getBoolean('base64attributes', FALSE); + } + if ($base64Attributes) { $defaultEncoding = 'base64'; } else { $defaultEncoding = 'string'; } - $encodings = $dstMetadata->getArray('attributeencodings', array()); + $srcEncodings = $srcMetadata->getArray('attributeencodings', array()); + $dstEncodings = $dstMetadata->getArray('attributeencodings', array()); + + /* + * Merge the two encoding arrays. Encodings specified in the target metadata + * takes precedence over the source metadata. + */ + $encodings = array_merge($srcEncodings, $dstEncodings); $ret = array(); foreach ($attributes as $name => $values) { -- GitLab