public function SearchSubscriber::getDerivedKey in Acquia Search Multiple Indexes 8
Get the derived key for the solr hmac using the information shared with acquia.com.
Parameters
null $env_id:
Return value
mixed
2 calls to SearchSubscriber::getDerivedKey()
- SearchSubscriber::calculateAuthCookie in src/
EventSubscriber/ SearchSubscriber.php - Creates an authenticator based on a data string and HMAC-SHA1.
- SearchSubscriber::validateResponse in src/
EventSubscriber/ SearchSubscriber.php - Validate the authenticity of returned data using a nonce and HMAC-SHA1.
File
- src/
EventSubscriber/ SearchSubscriber.php, line 137
Class
Namespace
Drupal\acquia_search_multi_subs\EventSubscriberCode
public function getDerivedKey($env_id = NULL) {
if (empty($env_id)) {
$env_id = $this->client
->getEndpoint()
->getKey();
}
if (!isset($this->derived_key[$env_id])) {
// If we set an explicit environment, check if this needs to overridden
// Use the default.
$identifier = \Drupal::config('acquia_connector.settings')
->get('identifier');
$key = \Drupal::config('acquia_connector.settings')
->get('key');
// See if we need to overwrite these values
// 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 = $this
->getDerivedKeySalt();
// 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.
$this->derived_key[$env_id] = '';
}
elseif (!isset($derived_key[$env_id])) {
$this->derived_key[$env_id] = CryptConnector::createDerivedKey($derived_key_salt, $env_id, $key);
}
}
return $this->derived_key[$env_id];
}