You are here

function acquia_agent_valid_response in Acquia Connector 7.3

Same name and namespace in other branches
  1. 6.2 acquia_agent/acquia_agent_streams.inc \acquia_agent_valid_response()
  2. 6 acquia_agent/acquia_agent_streams.inc \acquia_agent_valid_response()
  3. 7 acquia_agent/acquia_agent.module \acquia_agent_valid_response()
  4. 7.2 acquia_agent/acquia_agent.module \acquia_agent_valid_response()

Determine if a response from Acquia is valid.

Parameters

array $data: The data array returned by acquia_agent_call(). Expected keys: 'authenticator' - request authenticator sent to server 'result' - response from server including keys 'authenticator' - server response authenticator 'body' - server response body.

string $key: Acquia subscription key.

Return value

bool Response.

2 calls to acquia_agent_valid_response()
acquia_agent_get_subscription in acquia_agent/acquia_agent.module
Get subscription status from Acquia.
acquia_spi_send_data in acquia_spi/acquia_spi.module
Send data to Acquia Insight.

File

acquia_agent/acquia_agent.module, line 791
Acquia Agent securely sends information to Acquia Insight.

Code

function acquia_agent_valid_response(array $data, $key = NULL) {
  $authenticator = $data['authenticator'];
  $result = $data['result'];
  $result_auth = $result['authenticator'];
  $valid = $authenticator['nonce'] == $result_auth['nonce'];
  $valid = $valid && $authenticator['time'] < $result_auth['time'];
  if (empty($key)) {
    $key = acquia_agent_settings('acquia_key');
  }
  $hash = _acquia_agent_hmac($key, $result_auth['time'], $result_auth['nonce'], $result['body']);
  return $valid && $hash == $result_auth['hash'];
}