You are here

private function AcquiaSearchSolrService::isValidResponse in Acquia Connector 7.3

Validates response.

Parameters

string $hmac: HMAC string.

string $nonce: Nonce.

string $string: Payload.

string|null $derived_key: Derived key.

string|null $env_id: Search environment ID.

Return value

bool TRUE if request is valid, otherwise - FALSE.

1 call to AcquiaSearchSolrService::isValidResponse()
AcquiaSearchSolrService::authenticateResponse in acquia_search/includes/AcquiaSearchSolrService.php
Makes authentication checks.

File

acquia_search/includes/AcquiaSearchSolrService.php, line 278

Class

AcquiaSearchSolrService
Class AcquiaSearchSolrService.

Code

private function isValidResponse($hmac, $nonce, $string, $derived_key = NULL, $env_id = NULL) {
  if (empty($env_id)) {
    $env_id = apachesolr_default_environment();
  }
  if (empty($derived_key)) {
    $environment = apachesolr_environment_load($env_id);
    if (empty($environment['url'])) {
      return FALSE;
    }
    $index_id = substr($environment['url'], strrpos($environment['url'], '/') + 1);
    $api = _acquia_search_solr_get_api();
    if (empty($api)) {
      return FALSE;
    }
    $indexes = $api
      ->getIndexes();
    if (empty($indexes[$index_id]['data'])) {
      return FALSE;
    }
    $derived_key = $this
      ->createDerivedKey($indexes[$index_id]['data']['product_policies']['salt'], $indexes[$index_id]['data']['key'], $indexes[$index_id]['data']['secret_key']);
  }
  return $hmac === hash_hmac('sha1', $nonce . $string, $derived_key);
}