Definition at line 10 of file Metadata.php.
◆ getContact()
static SimpleSAML\Utils\Config\Metadata::getContact |
( |
|
$contact | ) |
|
|
static |
Parse and sanitize a contact from an array.
Accepts an array with the following elements:
- 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.
The following values are allowed as "contactType":
- technical
- support
- administrative
- 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.
- Parameters
-
array | $contact | The contact to parse and sanitize. |
- Returns
- 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.
- Exceptions
-
Definition at line 101 of file Metadata.php.
References $names, and $t.
103 if (!(is_array($contact) || is_null($contact))) {
104 throw new \InvalidArgumentException(
'Invalid input parameters');
108 if (!isset($contact[
'contactType']) || !in_array($contact[
'contactType'], self::$VALID_CONTACT_TYPES,
true)) {
109 $types = join(
', ', array_map(
113 self::$VALID_CONTACT_TYPES
115 throw new \InvalidArgumentException(
'"contactType" is mandatory and must be one of '.$types.
".");
119 if (isset($contact[
'attributes'])) {
120 if (empty($contact[
'attributes'])
121 || !is_array($contact[
'attributes'])
122 || count(array_filter(array_keys($contact[
'attributes']),
'is_string')) === 0
124 throw new \InvalidArgumentException(
'"attributes" must be an array and cannot be empty.');
129 if (isset($contact[
'name']) && !isset($contact[
'givenName']) && !isset($contact[
'surName'])) {
131 $names = explode(
',', $contact[
'name'], 2);
132 if (count(
$names) === 2) {
133 $contact[
'surName'] = preg_replace(
'/\s+/',
' ', trim(
$names[0]));
134 $contact[
'givenName'] = preg_replace(
'/\s+/',
' ', trim(
$names[1]));
137 $names = explode(
' ', preg_replace(
'/\s+/',
' ', trim($contact[
'name'])));
138 if (count(
$names) === 2) {
139 $contact[
'givenName'] = preg_replace(
'/\s+/',
' ', trim(
$names[0]));
140 $contact[
'surName'] = preg_replace(
'/\s+/',
' ', trim(
$names[1]));
143 $contact[
'givenName'] = preg_replace(
'/\s+/',
' ', trim($contact[
'name']));
149 if (isset($contact[
'givenName']) && (
150 empty($contact[
'givenName']) || !is_string($contact[
'givenName'])
153 throw new \InvalidArgumentException(
'"givenName" must be a string and cannot be empty.');
157 if (isset($contact[
'surName']) && (
158 empty($contact[
'surName']) || !is_string($contact[
'surName'])
161 throw new \InvalidArgumentException(
'"surName" must be a string and cannot be empty.');
165 if (isset($contact[
'company']) && (
166 empty($contact[
'company']) || !is_string($contact[
'company'])
169 throw new \InvalidArgumentException(
'"company" must be a string and cannot be empty.');
173 if (isset($contact[
'emailAddress'])) {
174 if (empty($contact[
'emailAddress']) ||
175 !(is_string($contact[
'emailAddress']) || is_array($contact[
'emailAddress']))
177 throw new \InvalidArgumentException(
'"emailAddress" must be a string or an array and cannot be empty.');
179 if (is_array($contact[
'emailAddress'])) {
180 foreach ($contact[
'emailAddress'] as $address) {
181 if (!is_string($address) || empty($address)) {
182 throw new \InvalidArgumentException(
'Email addresses must be a string and cannot be empty.');
189 if (isset($contact[
'telephoneNumber'])) {
190 if (empty($contact[
'telephoneNumber']) ||
191 !(is_string($contact[
'telephoneNumber']) || is_array($contact[
'telephoneNumber']))
193 throw new \InvalidArgumentException(
194 '"telephoneNumber" must be a string or an array and cannot be empty.' 197 if (is_array($contact[
'telephoneNumber'])) {
198 foreach ($contact[
'telephoneNumber'] as $address) {
199 if (!is_string($address) || empty($address)) {
200 throw new \InvalidArgumentException(
'Telephone numbers must be a string and cannot be empty.');
207 return array_intersect_key($contact, array_flip(self::$VALID_CONTACT_OPTIONS));
◆ getDefaultEndpoint()
static SimpleSAML\Utils\Config\Metadata::getDefaultEndpoint |
( |
array |
$endpoints, |
|
|
array |
$bindings = null |
|
) |
| |
|
static |
Find the default endpoint in an endpoint array.
- Parameters
-
array | $endpoints | An array with endpoints. |
array | $bindings | An array with acceptable bindings. Can be null if any binding is allowed. |
- Returns
- array|NULL The default endpoint, or null if no acceptable endpoints are used.
- Author
- Olav Morken, UNINETT AS olav..nosp@m.mork.nosp@m.en@un.nosp@m.inet.nosp@m.t.no
Definition at line 221 of file Metadata.php.
References $bindings.
223 $firstNotFalse = null;
224 $firstAllowed = null;
227 foreach ($endpoints as $ep) {
233 if (array_key_exists(
'isDefault', $ep)) {
234 if ($ep[
'isDefault'] ===
true) {
239 if ($firstAllowed === null) {
244 if ($firstNotFalse === null) {
246 $firstNotFalse = $ep;
251 if ($firstNotFalse !== null) {
253 return $firstNotFalse;
259 return $firstAllowed;
◆ isHiddenFromDiscovery()
static SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery |
( |
array |
$metadata | ) |
|
|
static |
Determine if an entity should be hidden in the discovery service.
This method searches for the "Hide From Discovery" REFEDS Entity Category, and tells if the entity should be hidden or not depending on it.
- See also
- https://refeds.org/category/hide-from-discovery
- Parameters
-
array | $metadata | An associative array with the metadata representing an entity. |
- Returns
- boolean True if the entity should be hidden, false otherwise.
Definition at line 275 of file Metadata.php.
References SimpleSAML\Logger\maskErrors(), and SimpleSAML\Logger\popErrorMask().
278 $hidden = in_array(self::$HIDE_FROM_DISCOVERY,
$metadata[
'EntityAttributes'][self::$ENTITY_CATEGORY],
true);
280 return $hidden ===
true;
static popErrorMask()
Pop an error mask.
$metadata['__DYNAMIC:1__']
static maskErrors($mask)
Disable error reporting for the given log levels.
◆ $ENTITY_CATEGORY
SimpleSAML\Utils\Config\Metadata::$ENTITY_CATEGORY = 'http://macedir.org/entity-category' |
|
static |
◆ $HIDE_FROM_DISCOVERY
SimpleSAML\Utils\Config\Metadata::$HIDE_FROM_DISCOVERY = 'http://refeds.org/category/hide-from-discovery' |
|
static |
◆ $VALID_CONTACT_OPTIONS
SimpleSAML\Utils\Config\Metadata::$VALID_CONTACT_OPTIONS |
|
static |
Initial value: 'contactType',
'emailAddress',
'givenName',
'surName',
'telephoneNumber',
'company',
'attributes',
)
Definition at line 39 of file Metadata.php.
◆ $VALID_CONTACT_TYPES
SimpleSAML\Utils\Config\Metadata::$VALID_CONTACT_TYPES |
|
static |
Initial value: 'technical',
'support',
'administrative',
'billing',
'other',
)
Definition at line 54 of file Metadata.php.
The documentation for this class was generated from the following file:
- libs/composer/vendor/simplesamlphp/simplesamlphp/lib/SimpleSAML/Utils/Config/Metadata.php