function saml_sp__configure_idp_form_submit in SAML Service Provider 7.2
Same name and namespace in other branches
- 7.8 saml_sp.admin.inc \saml_sp__configure_idp_form_submit()
- 7 saml_sp.admin.inc \saml_sp__configure_idp_form_submit()
- 7.3 saml_sp.admin.inc \saml_sp__configure_idp_form_submit()
Submit handler for the SAML IDP configuration form.
File
- ./
saml_sp.admin.inc, line 241 - Admin pages for the SAML Service Provider module.
Code
function saml_sp__configure_idp_form_submit($form, &$form_state) {
// handle multiple certs
$certs = array();
foreach ($form_state['values']['idp_x509_certs'] as $cert) {
if (!empty($cert['cert'])) {
$certs[] = $cert['cert'];
}
}
// handle multiple Authn Contexts
$contexts = array();
foreach ($form_state['values']['authn_context_class_ref'] as $value) {
if ($value) {
$contexts[] = $value;
}
}
// Redirect to the admin overview page.
if (!empty($form['#destination'])) {
$form_state['redirect'] = $form['#destination'];
}
$idp = (object) array(
'name' => $form_state['values']['name'],
'machine_name' => $form_state['values']['machine_name'],
'app_name' => $form_state['values']['app_name'],
'entity_id' => $form_state['values']['entity_id'],
'nameid_field' => $form_state['values']['nameid_field'],
'login_url' => $form_state['values']['idp_login_url'],
'logout_url' => $form_state['values']['idp_logout_url'],
'x509_certs' => $certs,
'authn_context_class_ref' => implode('|', $contexts),
'export_type' => $form_state['values']['export_type'],
);
// Machine names can be changed.
if (isset($form_state['values']['orig_machine_name']) && $form_state['values']['orig_machine_name'] != $form_state['values']['machine_name']) {
$idp->orig_machine_name = $form_state['values']['orig_machine_name'];
}
$result = saml_sp_idp_save($idp);
switch ($result) {
case SAVED_NEW:
drupal_set_message(t('IdP %idp_name has been created.', array(
'%idp_name' => $form_state['values']['name'],
)));
break;
case SAVED_UPDATED:
drupal_set_message(t('IdP %idp_name has been updated.', array(
'%idp_name' => $form_state['values']['name'],
)));
break;
default:
drupal_set_message(t('An error occurred, IdP %idp_name has not been saved.', array(
'%idp_name' => $form_state['values']['name'],
)), 'error');
break;
}
}