You are here

protected function RestClient::setEncryption in Salesforce Suite 8.3

Set the given encryption profile as active.

If given profile is null, decrypt and disable encryption.

Parameters

\Drupal\encrypt\EncryptionProfileInterface|null $profile: The encryption profile. If null, encryption will be disabled.

2 calls to RestClient::setEncryption()
RestClient::disableEncryption in modules/salesforce_encrypt/src/Rest/RestClient.php
Decrypt and re-save sensitive salesforce config values.
RestClient::enableEncryption in modules/salesforce_encrypt/src/Rest/RestClient.php
Encrypts all sensitive salesforce config values.

File

modules/salesforce_encrypt/src/Rest/RestClient.php, line 127

Class

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

Namespace

Drupal\salesforce_encrypt\Rest

Code

protected function setEncryption(EncryptionProfileInterface $profile = NULL) {
  if (!$this->lock
    ->acquire('salesforce_encrypt')) {
    throw new \RuntimeException('Unable to acquire lock.');
  }
  $access_token = $this
    ->getAccessToken();
  $refresh_token = $this
    ->getRefreshToken();
  $identity = $this
    ->getIdentity();
  $consumerKey = $this
    ->getConsumerKey();
  $consumerSecret = $this
    ->getConsumerSecret();
  $this->encryptionProfileId = $profile == NULL ? NULL : $profile
    ->id();
  $this->encryptionProfile = $profile;
  $this->state
    ->set('salesforce_encrypt.profile', $this->encryptionProfileId);
  $this
    ->setAccessToken($access_token);
  $this
    ->setRefreshToken($refresh_token);
  $this
    ->setIdentity($identity);
  $this
    ->setConsumerKey($consumerKey);
  $this
    ->setConsumerSecret($consumerSecret);
  $this->lock
    ->release('salesforce_encrypt');
}