You are here

public function RestClient::getIdentity in Salesforce Suite 8.3

Same name in this branch
  1. 8.3 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::getIdentity()
  2. 8.3 modules/salesforce_encrypt/src/Rest/RestClient.php \Drupal\salesforce_encrypt\Rest\RestClient::getIdentity()

Return the Salesforce identity, which is stored in a variable.

Return value

array|FALSE Returns FALSE is no identity has been stored.

Overrides RestClientInterface::getIdentity

Deprecated

in 8.x-4.0, use \Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface::retrieveIdentity instead.

3 calls to RestClient::getIdentity()
RestClient::getApiEndPoint in src/Rest/RestClient.php
Get the API end point for a given type of the API.
RestClient::getIdentity in modules/salesforce_encrypt/src/Rest/RestClient.php
Return the Salesforce identity, which is stored in a variable.
RestClient::getVersions in src/Rest/RestClient.php
Wrapper for "Versions" resource to list information about API releases.
1 method overrides RestClient::getIdentity()
RestClient::getIdentity in modules/salesforce_encrypt/src/Rest/RestClient.php
Return the Salesforce identity, which is stored in a variable.

File

src/Rest/RestClient.php, line 565

Class

RestClient
Objects, properties, and methods to communicate with the Salesforce REST API.

Namespace

Drupal\salesforce\Rest

Code

public function getIdentity() {
  $identity = $this->state
    ->get('salesforce.identity');
  if (!$identity) {
    return FALSE;
  }
  $id_url_scheme = parse_url($identity['id']);
  $allowed_endpoint = $this
    ->getLoginUrl();
  $allowed_endpoint_url_scheme = parse_url($allowed_endpoint);
  if ($this->immutableConfig
    ->get('endpoint_verification') && $id_url_scheme['host'] != $allowed_endpoint_url_scheme['host']) {
    throw new Exception('Salesforce identity does not match salesforce endpoint: you need to re-authenticate.');
  }
  return $identity;
}