You are here

public function SimplesamlphpAuthManager::getAttribute in simpleSAMLphp Authentication 8.3

Get a specific SimpleSAML attribute.

Parameters

string $attribute: The name of the attribute.

Return value

mixed|bool The attribute value or FALSE.

Throws

\Drupal\simplesamlphp_auth\Exception\SimplesamlphpAttributeException Exception when attribute is not set.

3 calls to SimplesamlphpAuthManager::getAttribute()
SimplesamlphpAuthManager::getAuthname in src/Service/SimplesamlphpAuthManager.php
Gets the unique id of the user from the IdP.
SimplesamlphpAuthManager::getDefaultEmail in src/Service/SimplesamlphpAuthManager.php
Gets the mail attribute.
SimplesamlphpAuthManager::getDefaultName in src/Service/SimplesamlphpAuthManager.php
Gets the name attribute.

File

src/Service/SimplesamlphpAuthManager.php, line 275

Class

SimplesamlphpAuthManager
Service to interact with the SimpleSAMLPHP authentication library.

Namespace

Drupal\simplesamlphp_auth\Service

Code

public function getAttribute($attribute) {
  $attributes = $this
    ->getAttributes();
  if (isset($attributes)) {
    if (!empty($attributes[$attribute][0])) {
      return $attributes[$attribute][0];
    }
  }
  throw new SimplesamlphpAttributeException(sprintf('Error in simplesamlphp_auth.module: no valid "%s" attribute set.', $attribute));
}