You are here

public function SearchSubscriber::calculateAuthCookie in Acquia Search 2.x

Same name and namespace in other branches
  1. 3.x src/EventSubscriber/SearchSubscriber.php \Drupal\acquia_search\EventSubscriber\SearchSubscriber::calculateAuthCookie()

Creates an authenticator based on a data string and HMAC-SHA1.

Parameters

string $string: Data string.

string $nonce: Nonce.

int $time: Request time.

string $derived_key: Derived key.

string $env_id: Environment Id.

Return value

string Auth cookie string.

1 call to SearchSubscriber::calculateAuthCookie()
SearchSubscriber::preExecuteRequest in src/EventSubscriber/SearchSubscriber.php
Build Acquia Search Solr Authenticator.

File

src/EventSubscriber/SearchSubscriber.php, line 304

Class

SearchSubscriber
Extends Solarium plugin: authenticate, etc.

Namespace

Drupal\acquia_search\EventSubscriber

Code

public function calculateAuthCookie($string, $nonce, $time, $derived_key = NULL, $env_id = NULL) {
  if (empty($derived_key)) {
    $derived_key = $this
      ->getDerivedKey($env_id);
  }
  if (empty($derived_key)) {

    // Expired or invalid subscription - don't continue.
    return '';
  }
  else {
    return 'acquia_solr_time=' . $time . '; acquia_solr_nonce=' . $nonce . '; acquia_solr_hmac=' . hash_hmac('sha1', $time . $nonce . $string, $derived_key) . ';';
  }
}