public function SamlSpConfigSPForm::buildForm in SAML Service Provider 7.8
File
- src/
Form/ SamlSpConfigSPForm.php, line 90 - Contains \Drupal\saml_sp\Form\SamlSpConfigSPForm.
Class
Namespace
Drupal\saml_sp\FormCode
public function buildForm(array $form = [], FormStateInterface $form_state) {
$config = $this
->config('saml_sp.settings');
$form['contact'] = array(
'#type' => 'fieldset',
'#title' => t('Contact Information'),
'#description' => t('Information to be included in the federation metadata.'),
'#tree' => TRUE,
);
$form['contact']['technical'] = array(
'#type' => 'fieldset',
'#title' => t('Technical'),
);
$form['contact']['technical']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $config
->get('contact.technical.name'),
);
$form['contact']['technical']['email'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#default_value' => $config
->get('contact.technical.email'),
);
$form['contact']['support'] = array(
'#type' => 'fieldset',
'#title' => t('Support'),
);
$form['contact']['support']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $config
->get('contact.support.name'),
);
$form['contact']['support']['email'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#default_value' => $config
->get('contact.support.email'),
);
$form['organization'] = array(
'#type' => 'fieldset',
'#title' => t('Organization'),
'#description' => t('Organization information for the federation metadata'),
'#tree' => TRUE,
);
$form['organization']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#description' => t('This is a short name for the organization'),
'#default_value' => $config
->get('organization.name'),
);
$form['organization']['display_name'] = array(
'#type' => 'textfield',
'#title' => t('Display Name'),
'#description' => t('This is a long name for the organization'),
'#default_value' => $config
->get('organization.display_name'),
);
$form['organization']['url'] = array(
'#type' => 'textfield',
'#title' => t('URL'),
'#description' => t('This is a URL for the organization'),
'#default_value' => $config
->get('organization.url'),
);
$form['strict'] = array(
'#type' => 'checkbox',
'#title' => t('Strict Protocol'),
'#description' => t('SAML 2 Strict protocol will be used.'),
'#default_value' => $config
->get('strict'),
);
$form['security'] = array(
'#type' => 'fieldset',
'#title' => t('Security'),
'#tree' => TRUE,
);
$form['security']['offered'] = array(
'#markup' => t('Signatures and Encryptions Offered:'),
);
$form['security']['nameIdEncrypted'] = array(
'#type' => 'checkbox',
'#title' => t('NameID Encrypted'),
'#default_value' => $config
->get('security.nameIdEncrypted'),
);
$form['security']['authnRequestsSigned'] = array(
'#type' => 'checkbox',
'#title' => t('Authn Requests Signed'),
'#default_value' => $config
->get('security.authnRequestsSigned'),
);
$form['security']['logoutRequestSigned'] = array(
'#type' => 'checkbox',
'#title' => t('Logout Requests Signed'),
'#default_value' => $config
->get('security.logoutRequestSigned'),
);
$form['security']['logoutResponseSigned'] = array(
'#type' => 'checkbox',
'#title' => t('Logout Response Signed'),
'#default_value' => $config
->get('security.logoutResponseSigned'),
);
$form['security']['required'] = array(
'#markup' => t('Signatures and Encryptions Required:'),
);
$form['security']['wantMessagesSigned'] = array(
'#type' => 'checkbox',
'#title' => t('Want Messages Signed'),
'#default_value' => $config
->get('security.wantMessagesSigned'),
);
$form['security']['wantAssertionsSigned'] = array(
'#type' => 'checkbox',
'#title' => t('Want Assertions Signed'),
'#default_value' => $config
->get('security.wantAssertionsSigned'),
);
$form['security']['wantNameIdEncrypted'] = array(
'#type' => 'checkbox',
'#title' => t('Want NameID Encrypted'),
'#default_value' => $config
->get('security.wantNameIdEncrypted'),
);
$form['security']['metadata'] = array(
//'#type' => 'markup',
'#markup' => t('Metadata:'),
);
$form['security']['signMetaData'] = array(
'#type' => 'checkbox',
'#title' => t('Sign Meta Data'),
'#default_value' => $config
->get('security.signMetaData'),
);
$form['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' => $config
->get('cert_location'),
);
$form['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' => $config
->get('key_location'),
);
$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' => variable_get('saml_sp_drupal_login__idp', ''),
'!link' => l(t('here'), saml_sp__metadata_url()),
)),
'#disabled' => TRUE,
'#rows' => 20,
'#default_value' => $metadata,
);
}
else {
$form['metadata']['none'] = array(
'#markup' => $no_metadata,
);
}
/*
if ( module_exists('devel')) {
$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 parent::buildForm($form, $form_state);
}