config.inc in Key 7.3
File
plugins/key_provider/config.inc
View source
<?php
$plugin = array(
'label' => t('Configuration'),
'description' => t('The Configuration key provider stores the key in configuration in the database.'),
'storage method' => 'config',
'key value' => array(
'accepted' => TRUE,
'required' => FALSE,
),
'default configuration' => 'key_provider_config_default_configuration',
'build configuration form' => 'key_provider_config_build_configuration_form',
'get key value' => 'key_provider_config_get_key_value',
'set key value' => 'key_provider_config_set_key_value',
'delete key value' => 'key_provider_config_delete_key_value',
'obscure key value' => 'key_provider_config_obscure_key_value',
);
function key_provider_config_default_configuration() {
return array(
'base64_encoded' => FALSE,
);
}
function key_provider_config_build_configuration_form($form, &$form_state) {
$config = $form_state['storage']['key_config'];
$plugin_config = $form_state['storage']['key_config']['key_provider_settings'] + key_provider_config_default_configuration();
$key_type = key_get_plugin('key_type', $config['key_type']);
if ($key_type['group'] == 'encryption') {
$form['base64_encoded'] = array(
'#type' => 'checkbox',
'#title' => t('Base64-encoded'),
'#description' => t('Checking this will store the key with Base64 encoding.'),
'#default_value' => $plugin_config['base64_encoded'],
);
}
return $form;
}
function key_provider_config_get_key_value($config) {
$key_value = isset($config['key_provider_settings']['key_value']) ? $config['key_provider_settings']['key_value'] : '';
if (isset($config['key_provider_settings']['base64_encoded']) && $config['key_provider_settings']['base64_encoded'] == TRUE) {
$key_value = base64_decode($key_value);
}
return $key_value;
}
function key_provider_config_set_key_value($config, &$form_state, $key_value) {
if (isset($config['key_provider_settings']['base64_encoded']) && $config['key_provider_settings']['base64_encoded'] == TRUE) {
$key_value = base64_encode($key_value);
}
if ($form_state['values']['key_value'] = $key_value) {
return TRUE;
}
else {
return FALSE;
}
}
function key_provider_config_delete_key_value($config) {
return TRUE;
}
function key_provider_config_obscure_key_value($key_value, $options = array()) {
return $key_value;
}