Skip to content
Snippets Groups Projects
Commit 32063a86 authored by Tyler Antonio's avatar Tyler Antonio
Browse files

Add ability to define additional attributes on ContactPerson element

parent d66b9fd9
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@
"ext-date": "*",
"ext-hash": "*",
"ext-json": "*",
"simplesamlphp/saml2": "dev-master#00e38f85b417be1e10a2d738dd2f5ea82edb472c as 2.2",
"simplesamlphp/saml2": "dev-master#a94403bfe5627c90fe3764e0ada5a44841a11e80 as 2.3.3",
"robrichards/xmlseclibs": "~2.0",
"whitehat101/apr1-md5": "~1.0",
"twig/twig": "~1.0",
......
......@@ -688,6 +688,10 @@ class SimpleSAML_Metadata_SAMLBuilder
$e = new \SAML2\XML\md\ContactPerson();
$e->contactType = $type;
if (!empty($details['attributes'])) {
$e->ContactPersonAttributes = $details['attributes'];
}
if (isset($details['company'])) {
$e->Company = $details['company'];
}
......
......@@ -27,6 +27,12 @@ class Metadata
/**
* Valid options for the ContactPerson element
*
* The 'attributes' option isn't defined in section 2.3.2.2 of the OASIS document, but
* it is required to allow additons to the main contact person element for trust
* frameworks.
*
* @var array The valid configuration options for a contact configuration array.
* @see "Metadata for the OASIS Security Assertion Markup Language (SAML) V2.0", section 2.3.2.2.
*/
......@@ -37,6 +43,7 @@ class Metadata
'surName',
'telephoneNumber',
'company',
'attributes',
);
......@@ -108,6 +115,13 @@ class Metadata
throw new \InvalidArgumentException('"contactType" is mandatory and must be one of '.$types.".");
}
// check attributes is an associative array
if (isset($contact['attributes'])) {
if (empty($contact['attributes']) || empty(array_filter(array_keys($contact['attributes']), 'is_string'))) {
throw new \InvalidArgumentException('"attributes" must be an array and cannot be empty.');
}
}
// try to fill in givenName and surName from name
if (isset($contact['name']) && !isset($contact['givenName']) && !isset($contact['surName'])) {
// first check if it's comma separated
......
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