You are here

function _acquia_search_derived_key in Acquia Search 6.3

Same name and namespace in other branches
  1. 6 acquia_search.module \_acquia_search_derived_key()

Get the derived key for the solr hmac using the information shared with acquia.com.

2 calls to _acquia_search_derived_key()
acquia_search_authenticator in ./acquia_search.module
Creates an authenticator based on a data string and HMAC-SHA1.
acquia_search_valid_response in ./acquia_search.module
Validate the authenticity of returned data using a nonce and HMAC-SHA1.

File

./acquia_search.module, line 355
Integration between Acquia Drupal and Acquia's hosted solr search service.

Code

function _acquia_search_derived_key($env_id = NULL) {
  static $derived_key = array();
  if (empty($env_id)) {
    $env_id = 0;
  }
  if (!isset($derived_key[$env_id])) {

    // If we set an explicit environment, check if this needs to overridden
    // Use the default
    $identifier = acquia_agent_settings('acquia_identifier');
    $key = acquia_agent_settings('acquia_key');

    // See if we need to overwrite these values
    if ($env_id) {

      // Load the explicit environment and a manually set search key.
      if ($search_key = apachesolr_environment_variable_get($env_id, 'acquia_search_key')) {
        $derived_key[$env_id] = $search_key;
      }
    }

    // In any case, this is equal for all subscriptions. Also
    // even if the search sub is different, the main subscription should be
    // active
    $derived_key_salt = acquia_search_derived_key_salt();

    // value that we could change on the AN side if needed to force any
    // or all clients to use a new derived key.  We also use a string
    // ('solr') specific to the service, since we want each service using a
    // derived key to have a separate one.
    if (empty($derived_key_salt) || empty($key) || empty($identifier)) {

      // Expired or invalid subscription - don't continue.
      $derived_key[$env_id] = '';
    }
    elseif (!isset($derived_key[$env_id])) {
      $derived_key[$env_id] = _acquia_search_create_derived_key($derived_key_salt, $identifier, $key);
    }
  }
  return $derived_key[$env_id];
}