private function enc_attribute($name, $values, $base64, $scopedAttributes)
{
assert('is_string($name)');
assert('is_array($values)');
assert('is_bool($base64)');
assert('is_array($scopedAttributes)');
if (in_array($name, $scopedAttributes, TRUE)) {
$scoped = TRUE;
} else {
$scoped = FALSE;
}
$attr = '<Attribute AttributeName="' . htmlspecialchars($name) . '" AttributeNamespace="urn:mace:shibboleth:1.0:attributeNamespace:uri">';
foreach ($values as $value) {
$scopePart = '';
if ($scoped) {
$tmp = explode('@', $value, 2);
if (count($tmp) === 2) {
$value = $tmp[0];
$scopePart = ' Scope="' . htmlspecialchars($tmp[1]) . '"';
}
}
if ($base64) {
$value = base64_encode($value);
}
$attr .= '<AttributeValue' . $scopePart . '>' . htmlspecialchars($value) . '</AttributeValue>';
}
$attr .= '</Attribute>';
return $attr;
}