function saml_sp__get_metadata in SAML Service Provider 7.2
Same name and namespace in other branches
- 8.3 saml_sp.module \saml_sp__get_metadata()
- 8.2 saml_sp.module \saml_sp__get_metadata()
- 7.8 saml_sp.module \saml_sp__get_metadata()
- 7.3 saml_sp.module \saml_sp__get_metadata()
- 4.x saml_sp.module \saml_sp__get_metadata()
- 3.x saml_sp.module \saml_sp__get_metadata()
load the settings and get the metadata
1 call to saml_sp__get_metadata()
- saml_sp__admin_config in ./
saml_sp.admin.inc - configure this SAML Service Provider
1 string reference to 'saml_sp__get_metadata'
- saml_sp_menu in ./
saml_sp.module - Implements hook_menu().
File
- ./
saml_sp.module, line 583 - 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);
if (empty($settings)) {
return array(
t('Settings could not be loaded and metadata couldn\'t be generated.'),
);
}
$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,
);
}
}