diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index b14a26f3064f0536e8a590a3e2182cb532f70b11..5376fee2442ebc74cf593accbf68c3033ee8f2f6 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -535,7 +535,7 @@ class SAMLBuilder foreach ($metadata->getArray('contacts', []) as $contact) { if (array_key_exists('contactType', $contact) && array_key_exists('emailAddress', $contact)) { - $this->addContact($contact['contactType'], Utils\Config\Metadata::getContact($contact)); + $this->addContact(Utils\Config\Metadata::getContact($contact)); } } } @@ -583,7 +583,7 @@ class SAMLBuilder foreach ($metadata->getArray('contacts', []) as $contact) { if (array_key_exists('contactType', $contact) && array_key_exists('emailAddress', $contact)) { - $this->addContact($contact['contactType'], Utils\Config\Metadata::getContact($contact)); + $this->addContact(Utils\Config\Metadata::getContact($contact)); } } } @@ -623,23 +623,15 @@ class SAMLBuilder /** * Add contact information. * - * Accepts a contact type, and a contact array that must be previously sanitized. + * Accepts a contact type, and a contact array that must be previously sanitized + * by calling Utils\Config\Metadata::getContact(). * - * WARNING: This function will change its signature and no longer parse a 'name' element. - * - * @param string $type The type of contact. Deprecated. * @param array $details The details about the contact. - * - * @todo Change the signature to remove $type. - * @todo Remove the capability to pass a name and parse it inside the method. */ - public function addContact(string $type, array $details): void + public function addContact(array $details): void { Assert::oneOf($type, ['technical', 'support', 'administrative', 'billing', 'other']); - // TODO: remove this check as soon as getContact() is called always before calling this function - $details = Utils\Config\Metadata::getContact($details); - $e = new \SAML2\XML\md\ContactPerson(); $e->setContactType($type); diff --git a/lib/SimpleSAML/Utils/Config/Metadata.php b/lib/SimpleSAML/Utils/Config/Metadata.php index 938eacf1e6ca7a8191156dab1c85c5825a3c88e1..25e5f171dbcbd9319bd972fe8bcdb9788fcc9fb8 100644 --- a/lib/SimpleSAML/Utils/Config/Metadata.php +++ b/lib/SimpleSAML/Utils/Config/Metadata.php @@ -72,7 +72,6 @@ class Metadata * - contactType The type of the contact (as string). Mandatory. * - emailAddress Email address (as string), or array of email addresses. Optional. * - telephoneNumber Telephone number of contact (as string), or array of telephone numbers. Optional. - * - name Full name of contact, either as <GivenName> <SurName>, or as <SurName>, <GivenName>. Optional. * - surName Surname of contact (as string). Optional. * - givenName Given name of contact (as string). Optional. * - company Company name of contact (as string). Optional. @@ -84,22 +83,11 @@ class Metadata * - billing * - other * - * If given a "name" it will try to decompose it into its given name and surname, only if neither givenName nor - * surName are present. It works as follows: - * - "surname1 surname2, given_name1 given_name2" - * givenName: "given_name1 given_name2" - * surname: "surname1 surname2" - * - "given_name surname" - * givenName: "given_name" - * surname: "surname" - * * otherwise it will just return the name as "givenName" in the resulting array. * * @param array|null $contact The contact to parse and sanitize. * - * @return array An array holding valid contact configuration options. If a key 'name' was part of the input array, - * it will try to decompose the name into its parts, and place the parts into givenName and surName, if those are - * missing. + * @return array An array holding valid contact configuration options. * @throws \InvalidArgumentException If $contact is neither an array nor null, or the contact does not conform to * valid configuration rules for contacts. */ @@ -131,26 +119,6 @@ class Metadata } } - // 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 - $names = explode(',', $contact['name'], 2); - if (count($names) === 2) { - $contact['surName'] = preg_replace('/\s+/', ' ', trim($names[0])); - $contact['givenName'] = preg_replace('/\s+/', ' ', trim($names[1])); - } else { - // check if it's in "given name surname" format - $names = explode(' ', preg_replace('/\s+/', ' ', trim($contact['name']))); - if (count($names) === 2) { - $contact['givenName'] = preg_replace('/\s+/', ' ', trim($names[0])); - $contact['surName'] = preg_replace('/\s+/', ' ', trim($names[1])); - } else { - // nothing works, return it as given name - $contact['givenName'] = preg_replace('/\s+/', ' ', trim($contact['name'])); - } - } - } - // check givenName if ( isset($contact['givenName']) diff --git a/modules/admin/lib/Controller/Federation.php b/modules/admin/lib/Controller/Federation.php index ffb6568bb57fae1fbf847bdd81972fa1527bda2d..81bb898ac5229f8e1b58c1f80f88cb17a0b171d2 100644 --- a/modules/admin/lib/Controller/Federation.php +++ b/modules/admin/lib/Controller/Federation.php @@ -255,7 +255,7 @@ class Federation $builder->addOrganizationInfo($entity['metadata_array']); if (isset($entity['metadata_array']['contacts'])) { foreach ($entity['metadata_array']['contacts'] as $contact) { - $builder->addContact($contact['contactType'], $contact); + $builder->addContact(Utils\Config\Metadata::getContact($contact)); } }