You are here

function key_provider_file_get_key_value in Key 7.3

Callback function to return a key from a file.

1 string reference to 'key_provider_file_get_key_value'
file.inc in plugins/key_provider/file.inc

File

plugins/key_provider/file.inc, line 97

Code

function key_provider_file_get_key_value($config) {
  if (empty($config['key_provider_settings']['file_location'])) {
    return NULL;
  }
  $file = $config['key_provider_settings']['file_location'];

  // Make sure the file exists and is readable.
  if (!is_file($file) || !is_readable($file)) {
    return NULL;
  }
  $key_value = file_get_contents($file);

  // Base64-decode if necessary.
  if (isset($config['key_provider_settings']['base64_encoded']) && $config['key_provider_settings']['base64_encoded']) {
    $key_value = base64_decode($key_value);
  }
  return $key_value;
}