You are here

function saml_sp__get_metadata in SAML Service Provider 7.8

Same name and namespace in other branches
  1. 8.3 saml_sp.module \saml_sp__get_metadata()
  2. 8.2 saml_sp.module \saml_sp__get_metadata()
  3. 7.2 saml_sp.module \saml_sp__get_metadata()
  4. 7.3 saml_sp.module \saml_sp__get_metadata()
  5. 4.x saml_sp.module \saml_sp__get_metadata()
  6. 3.x saml_sp.module \saml_sp__get_metadata()

load the settings and get the metadata

1 call to saml_sp__get_metadata()
SamlSpConfigSPForm::buildForm in src/Form/SamlSpConfigSPForm.php
1 string reference to 'saml_sp__get_metadata'
saml_sp_menu in ./saml_sp.module
Implements hook_menu().

File

./saml_sp.module, line 479
SAML Service Provider

Code

function saml_sp__get_metadata($idp, $output_page = FALSE) {

  /*
    if (empty($idp)) {
      // no $idp was given, we will try to see if there is a default one set
      $idp_selection = variable_get('saml_sp_drupal_login__idp', '');
      $idp = saml_sp_idp_load($idp_selection);
      if (empty($idp)) {
        // there is also no default $idp set
        if ($output_page) {
          // so return a page not found
          drupal_not_found();
          return;
        }
        else {
          throw new Exception('No Default IdP defined.');
          // return FALSE
          return FALSE;
        }
      }
    }

    $settings = saml_sp__get_settings($idp);

    $auth = new OneLogin_Saml2_Auth($settings);
    $settings = $auth->getSettings();
    $metadata = $settings->getSPMetadata();
    $errors = $settings->validateMetadata($metadata);
    if (empty($errors)) {
      if ($output_page) {
        drupal_add_http_header('Content-Type', 'text/xml');
        print $metadata;
      }
      else {
        return $metadata;
      }
    }
    else {
      return array($metadata, $errors);
    }/**/
}