public function SearchApiAcquiaSearchHttpTransport::getDerivedKey in Acquia Search for Search API 7
Derive a key for the solr hmac using the information shared with acquia.com.
See also
1 call to SearchApiAcquiaSearchHttpTransport::getDerivedKey()
- SearchApiAcquiaSearchHttpTransport::authenticator in includes/
SearchApiAcquiaSearchHttpTransport.php - Creates an authenticator based on a data string and HMAC-SHA1.
File
- includes/
SearchApiAcquiaSearchHttpTransport.php, line 56 - Contains SearchApiAcquiaSearchHttpTransport.
Class
- SearchApiAcquiaSearchHttpTransport
- HTTP transport for connections to the Acquia Search Service.
Code
public function getDerivedKey() {
if (!isset($this->derivedKey)) {
$key = acquia_agent_settings('acquia_key');
$subscription = acquia_agent_settings('acquia_subscription_data');
$identifier = acquia_agent_settings('acquia_identifier');
// 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($subscription['active']) || empty($key) || empty($identifier)) {
// Expired or invalid subscription - don't continue.
$this->derivedKey = '';
}
else {
$salt = isset($subscription['derived_key_salt']) ? $subscription['derived_key_salt'] : '';
$derivation_string = $identifier . 'solr' . $salt;
$this->derivedKey = hash_hmac('sha1', str_pad($derivation_string, 80, $derivation_string), $key);
}
}
return $this->derivedKey;
}