You are here

function key_provider_file_get_key in Key 7.2

Same name and namespace in other branches
  1. 7 plugins/key_provider/file.inc \key_provider_file_get_key()

Callback function to return a key from a file.

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

File

plugins/key_provider/file.inc, line 21

Code

function key_provider_file_get_key($config) {
  if (empty($config['provider_settings']['file_location'])) {
    return NULL;
  }
  $file = $config['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['provider_settings']['base64_encoded']) && $config['provider_settings']['base64_encoded']) {
    $key_value = base64_decode($key_value);
  }
  return $key_value;
}