You are here

private function SearchApiAcquiaSearchConnectionV3::isValidResponse in Acquia Search for Search API 7.2

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 SearchApiAcquiaSearchConnectionV3::isValidResponse()
SearchApiAcquiaSearchConnectionV3::authenticateResponse in includes/v3/SearchApiAcquiaSearchConnectionV3.php
Makes authentication checks.

File

includes/v3/SearchApiAcquiaSearchConnectionV3.php, line 283

Class

SearchApiAcquiaSearchConnectionV3
Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.

Code

private function isValidResponse($hmac, $nonce, $string, $derived_key = NULL) {
  if (empty($derived_key)) {
    $api = SearchApiAcquiaApi::getFromSettings();
    if (empty($api)) {
      return FALSE;
    }
    $core = $api
      ->getPreferredCoreService()
      ->getPreferredCore();
    if (empty($core['data'])) {
      return FALSE;
    }
    $derived_key = $this
      ->createDerivedKey($core['data']['product_policies']['salt'], $core['data']['key'], $core['data']['secret_key']);
  }
  return $hmac === hash_hmac('sha1', $nonce . $string, $derived_key);
}