You are here

public function AcsfSite::initSamlKeyProperties in Acquia Cloud Site Factory Connector 8.2

Same name and namespace in other branches
  1. 8 src/AcsfSite.php \Drupal\acsf\AcsfSite::initSamlKeyProperties()

Gets the SAML keys used by Site Factory SSO.

File

src/AcsfSite.php, line 226

Class

AcsfSite
AcsfSite.

Namespace

Drupal\acsf

Code

public function initSamlKeyProperties() {
  $sitegroup = $_ENV['AH_SITE_GROUP'];
  $env = $_ENV['AH_SITE_ENVIRONMENT'];
  $creds_path = "/mnt/files/{$sitegroup}.{$env}/nobackup/sf_shared_creds.ini";
  $credentials = file_get_contents($creds_path);
  $parsed_ini = parse_ini_string($credentials, TRUE);
  $this->info['saml_keys'] = [];
  if (isset($parsed_ini['saml']['tangle_key'])) {
    $this->info['saml_keys']['sp_private_key'] = $parsed_ini['saml']['tangle_key'];
  }
  else {
    $this->info['saml_keys']['sp_private_key'] = '';
  }
  if (isset($parsed_ini['saml']['tangle_cert'])) {
    $this->info['saml_keys']['sp_x509_certificate'] = $parsed_ini['saml']['tangle_cert'];
  }
  else {
    $this->info['saml_keys']['sp_x509_certificate'] = '';
  }
  if (isset($parsed_ini['saml']['factory_cert'])) {
    $this->info['saml_keys']['idp_x509_certificate'] = $parsed_ini['saml']['factory_cert'];
  }
  else {
    $this->info['saml_keys']['idp_x509_certificate'] = '';
  }
}