Skip to content
Snippets Groups Projects
Commit ec379ac3 authored by Jaime Perez's avatar Jaime Perez
Browse files

Start using the new helper function for contact configuration validation in...

Start using the new helper function for contact configuration validation in SAMLBuilder. Change the documentation to warn about upcoming changes.
parent 92df0796
Branches
Tags
No related merge requests found
...@@ -608,43 +608,23 @@ class SimpleSAML_Metadata_SAMLBuilder { ...@@ -608,43 +608,23 @@ class SimpleSAML_Metadata_SAMLBuilder {
/** /**
* Add contact information. * Add contact information.
* *
* Accepts a contact type, and an array of the following elements (all are optional): * Accepts a contact type, and a contact array that must be previously sanitized.
* - emailAddress Email address (as string), or array of email addresses.
* - telephoneNumber Telephone number of contact (as string), or array of telephone numbers.
* - name Full name of contact, either as <GivenName> <SurName>, or as <SurName>, <GivenName>.
* - surName Surname of contact.
* - givenName Givenname of contact.
* - company Company name of contact.
* *
* 'name' will only be used if neither givenName nor surName is present. * @param string $type The type of contact. Deprecated.
* @param array $details The details about the contact.
* *
* The following contact types are allowed: * @todo Change the signature to remove $type.
* "technical", "support", "administrative", "billing", "other" * @todo Remove the capability to pass a name and parse it inside the method.
* *
* @param string $type The type of contact. * @deprecated This function will change its signature and no longer parse a 'name' element.
* @param array $details The details about the contact.
*/ */
public function addContact($type, $details) { public function addContact($type, $details) {
assert('is_string($type)'); assert('is_string($type)');
assert('is_array($details)'); assert('is_array($details)');
assert('in_array($type, array("technical", "support", "administrative", "billing", "other"), TRUE)'); assert('in_array($type, array("technical", "support", "administrative", "billing", "other"), TRUE)');
/* Parse name into givenName and surName. */ // TODO: remove this check as soon as getContact() is called always before calling this function.
if (isset($details['name']) && empty($details['surName']) && empty($details['givenName'])) { $details = SimpleSAML_Utils_Config_Metadata::getContact($details);
$names = explode(',', $details['name'], 2);
if (count($names) === 2) {
$details['surName'] = trim($names[0]);
$details['givenName'] = trim($names[1]);
} else {
$names = explode(' ', $details['name'], 2);
if (count($names) === 2) {
$details['givenName'] = trim($names[0]);
$details['surName'] = trim($names[1]);
} else {
$details['surName'] = trim($names[0]);
}
}
}
$e = new SAML2_XML_md_ContactPerson(); $e = new SAML2_XML_md_ContactPerson();
$e->contactType = $type; $e->contactType = $type;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment