You are here

protected function Client::buildAuthenticator in Acquia Connector 8.2

Same name and namespace in other branches
  1. 8 src/Client.php \Drupal\acquia_connector\Client::buildAuthenticator()
  2. 3.x src/Client.php \Drupal\acquia_connector\Client::buildAuthenticator()

Build authenticator to sign requests to the Acquia.

Parameters

string $key: Secret key to use for signing the request.

int $request_time: Such as from \Drupal::time()->getRequestTime().

array $params: Optional parameters to include. 'identifier' - Network Identifier.

Return value

array Authenticator array.

3 calls to Client::buildAuthenticator()
Client::getSubscriptionCredentials in src/Client.php
Get account settings to use for creating request authorizations.
Client::nspiCall in src/Client.php
Prepare and send a REST request to Acquia with an authenticator.
ClientTest::buildAuthenticator in tests/src/Unit/AcquiaConnectorUnitTest.php
Build authenticator to sign requests to the Acquia.
1 method overrides Client::buildAuthenticator()
ClientTest::buildAuthenticator in tests/src/Unit/AcquiaConnectorUnitTest.php
Build authenticator to sign requests to the Acquia.

File

src/Client.php, line 371

Class

Client
Acquia connector client.

Namespace

Drupal\acquia_connector

Code

protected function buildAuthenticator($key, int $request_time, array $params = []) {
  $authenticator = [];
  if (isset($params['identifier'])) {

    // Put Subscription ID in authenticator but do not use in hash.
    $authenticator['identifier'] = $params['identifier'];
    unset($params['identifier']);
  }
  $nonce = $this
    ->getNonce();
  $authenticator['time'] = $request_time;
  $authenticator['hash'] = $this
    ->hash($key, $request_time, $nonce);
  $authenticator['nonce'] = $nonce;
  return $authenticator;
}