You are here

public function SamlService::getMetadata in SAML Authentication 8.2

Same name and namespace in other branches
  1. 8.3 src/SamlService.php \Drupal\samlauth\SamlService::getMetadata()
  2. 8 src/SamlService.php \Drupal\samlauth\SamlService::getMetadata()
  3. 4.x src/SamlService.php \Drupal\samlauth\SamlService::getMetadata()

Show metadata about the local sp. Use this to configure your saml2 IDP

Return value

mixed xml string representing metadata

Throws

OneLogin_Saml2_Error

File

src/SamlService.php, line 107

Class

SamlService
Governs communication between the SAML toolkit and the IDP / login behavior.

Namespace

Drupal\samlauth

Code

public function getMetadata() {
  $settings = $this
    ->getSamlAuth()
    ->getSettings();
  $metadata = $settings
    ->getSPMetadata();
  $errors = $settings
    ->validateMetadata($metadata);
  if (empty($errors)) {
    return $metadata;
  }
  else {
    throw new OneLogin_Saml2_Error('Invalid SP metadata: ' . implode(', ', $errors), OneLogin_Saml2_Error::METADATA_SP_INVALID);
  }
}