function saml_sp__admin_config in SAML Service Provider 7.3
Same name and namespace in other branches
- 7.2 saml_sp.admin.inc \saml_sp__admin_config()
configure this SAML Service Provider
1 string reference to 'saml_sp__admin_config'
- saml_sp_menu in ./
saml_sp.module - Implements hook_menu().
File
- ./
saml_sp.admin.inc, line 362 - Admin pages for the SAML Service Provider module.
Code
function saml_sp__admin_config($form, &$form_state) {
$library = _saml_sp__prepare();
$contact = variable_get('saml_sp__contact', FALSE);
$form['saml_sp__contact'] = array(
'#type' => 'fieldset',
'#title' => t('Contact Information'),
'#description' => t('Information to be included in the federation metadata.'),
'#tree' => TRUE,
);
$form['saml_sp__contact']['technical'] = array(
'#type' => 'fieldset',
'#title' => t('Technical'),
);
$form['saml_sp__contact']['technical']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $contact ? $contact['technical']['name'] : '',
);
$form['saml_sp__contact']['technical']['email'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#default_value' => $contact ? $contact['technical']['email'] : '',
);
$form['saml_sp__contact']['support'] = array(
'#type' => 'fieldset',
'#title' => t('Support'),
);
$form['saml_sp__contact']['support']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $contact ? $contact['support']['name'] : '',
);
$form['saml_sp__contact']['support']['email'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#default_value' => $contact ? $contact['support']['email'] : '',
);
$organization = variable_get('saml_sp__organization', FALSE);
$form['saml_sp__organization'] = array(
'#type' => 'fieldset',
'#title' => t('Organization'),
'#description' => t('Organization information for the federation metadata'),
'#tree' => TRUE,
);
$form['saml_sp__organization']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#description' => t('This is a short name for the organization'),
'#default_value' => $organization ? $organization['name'] : '',
);
$form['saml_sp__organization']['display_name'] = array(
'#type' => 'textfield',
'#title' => t('Display Name'),
'#description' => t('This is a long name for the organization'),
'#default_value' => $organization ? $organization['display_name'] : '',
);
$form['saml_sp__organization']['url'] = array(
'#type' => 'textfield',
'#title' => t('URL'),
'#description' => t('This is a URL for the organization'),
'#default_value' => $organization ? $organization['url'] : '',
);
$form['saml_sp__strict'] = array(
'#type' => 'checkbox',
'#title' => t('Strict Protocol'),
'#description' => t('SAML 2 Strict protocol will be used.'),
'#default_value' => variable_get('saml_sp__strict', FALSE),
);
$security = variable_get('saml_sp__security', FALSE);
$form['saml_sp__security'] = array(
'#type' => 'fieldset',
'#title' => t('Security'),
'#tree' => TRUE,
);
$form['saml_sp__security']['offered'] = array(
//'#type' => 'markup',
'#markup' => t('Signatures and Encryptions Offered:'),
);
$form['saml_sp__security']['nameIdEncrypted'] = array(
'#type' => 'checkbox',
'#title' => t('NameID Encrypted'),
'#default_value' => $security ? $security['nameIdEncrypted'] : '',
);
$form['saml_sp__security']['authnRequestsSigned'] = array(
'#type' => 'checkbox',
'#title' => t('Authn Requests Signed'),
'#default_value' => $security ? $security['authnRequestsSigned'] : '',
);
$form['saml_sp__security']['logoutRequestSigned'] = array(
'#type' => 'checkbox',
'#title' => t('Logout Requests Signed'),
'#default_value' => $security ? $security['logoutRequestSigned'] : '',
);
$form['saml_sp__security']['logoutResponseSigned'] = array(
'#type' => 'checkbox',
'#title' => t('Logout Response Signed'),
'#default_value' => $security ? $security['logoutResponseSigned'] : '',
);
$form['saml_sp__security']['required'] = array(
//'#type' => 'markup',
'#markup' => t('Signatures and Encryptions Required:'),
);
$form['saml_sp__security']['wantMessagesSigned'] = array(
'#type' => 'checkbox',
'#title' => t('Want Messages Signed'),
'#default_value' => $security ? $security['wantMessagesSigned'] : '',
);
$form['saml_sp__security']['wantAssertionsSigned'] = array(
'#type' => 'checkbox',
'#title' => t('Want Assertions Signed'),
'#default_value' => $security ? $security['wantAssertionsSigned'] : '',
);
$form['saml_sp__security']['wantNameIdEncrypted'] = array(
'#type' => 'checkbox',
'#title' => t('Want NameID Encrypted'),
'#default_value' => $security ? $security['wantNameIdEncrypted'] : '',
);
$form['saml_sp__security']['metadata'] = array(
//'#type' => 'markup',
'#markup' => t('Metadata:'),
);
$form['saml_sp__security']['signMetaData'] = array(
'#type' => 'checkbox',
'#title' => t('Sign Meta Data'),
'#default_value' => $security ? $security['signMetaData'] : '',
);
$form['saml_sp__cert_location'] = array(
'#type' => 'textfield',
'#title' => t('Certificate Location'),
'#description' => t('The location of the x.509 certificate file on the server. This must be a location that PHP can read.'),
'#default_value' => variable_get('saml_sp__cert_location', ''),
'#suffix' => saml_sp_get_cert_info(variable_get('saml_sp__cert_location', '')),
);
$form['saml_sp__key_location'] = array(
'#type' => 'textfield',
'#title' => t('Key Location'),
'#description' => t('The location of the x.509 key file on the server. This must be a location that PHP can read.'),
'#default_value' => variable_get('saml_sp__key_location', ''),
);
$form['saml_sp__new_cert_location'] = array(
'#type' => 'textfield',
'#title' => t('New Cert Location'),
'#description' => t('The location of the x.509 certificate file on the server. If the certificate above is about to expire add your new certificate here after you have obtained it. This will add the new certificate to the metadata to let the IdP know of the new certificate. This must be a location that PHP can read.'),
'#default_value' => variable_get('saml_sp__new_cert_location', ''),
'#suffix' => saml_sp_get_cert_info(variable_get('saml_sp__new_cert_location', '')),
);
if (module_exists('saml_sp_drupal_login')) {
$metadata_idp_machine_name = variable_get('saml_sp_drupal_login__idp', '');
}
else {
$idps = saml_sp__load_all_idps();
$options = array();
foreach ($idps as $idp_machine_name => $idp_data) {
$options[$idp_machine_name] = $idp_data->name;
}
$metadata_idp_machine_name = variable_get('saml_sp__idp_selection', '');
$form['saml_sp__idp_selection'] = array(
'#type' => 'select',
'#title' => t('IdP for Generating Metadata'),
'#description' => t('Please select an IdP to generate Federation Metadata for.'),
'#options' => $options,
'#empty_option' => t('Please select an IdP'),
'#default_value' => $metadata_idp_machine_name,
);
}
$error = FALSE;
try {
$metadata = saml_sp__get_metadata(NULL, FALSE);
if (is_array($metadata)) {
if (isset($metadata[1])) {
$errors = $metadata[1];
}
$metadata = $metadata[0];
}
} catch (Exception $e) {
drupal_set_message(t('Attempt to create metadata failed: %message.', array(
'%message' => $e
->getMessage(),
)), 'error');
$metadata = '';
$error = $e;
}
if (empty($metadata) && $error) {
$no_metadata = t('There is currently no metadata because of the following error: %error. Please resolve the error and return here for your metadata.', array(
'!url' => url('admin/config/people/saml_sp/drupal_login'),
'%error' => $error
->getMessage(),
));
}
$form['metadata'] = array(
'#type' => 'fieldset',
'#collapsed' => TRUE,
'#collapsible' => TRUE,
'#title' => t('Metadata'),
'#description' => t('This is the Federation Metadata for this IdP'),
);
if ($metadata) {
$form['metadata']['data'] = array(
'#type' => 'textarea',
'#title' => t('XML'),
'#description' => t('This metadata for @idp can also be accessed !link', array(
'@idp' => $metadata_idp_machine_name,
'!link' => l(t('here'), saml_sp__metadata_url()),
)),
'#disabled' => TRUE,
'#rows' => 20,
'#default_value' => $metadata,
);
}
else {
$form['metadata']['none'] = array(
'#markup' => $no_metadata,
);
}
$form['saml_sp__debug'] = array(
'#type' => 'checkbox',
'#title' => t('Debug'),
'#description' => t('Works with Devel module to display SAML requests and Responses for review.'),
'#default_value' => variable_get('saml_sp__debug', FALSE),
);
return system_settings_form($form);
}