function _acquia_search_derived_key in Acquia Search 6
Same name and namespace in other branches
- 6.3 acquia_search.module \_acquia_search_derived_key()
Derive a key for the solr hmac using the information shared with acquia.com.
3 calls to _acquia_search_derived_key()
- AcquiaSearchTest::testHMAC in tests/
acquia_search.test - 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 305 - Integration between Acquia Drupal and Acquia's hosted solr search service.
Code
function _acquia_search_derived_key() {
static $derived_key = NULL;
if (!isset($derived_key) && acquia_agent_subscription_is_active()) {
$key = acquia_agent_settings('acquia_key');
$identifier = acquia_agent_settings('acquia_identifier');
$derived_key_salt = acquia_search_derived_key_salt();
// We use a salt from acquia.com in key derivation since this is a shared
// 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 = '';
}
else {
$derivation_string = $identifier . 'solr' . $derived_key_salt;
$derived_key = _acquia_search_hmac($key, str_pad($derivation_string, 80, $derivation_string));
}
}
return $derived_key;
}