Esempio n. 1
0
 /**
  * @group utilities
  * @test
  */
 public function an_existing_readable_file_can_be_loaded()
 {
     $contents = SAML2_Utilities_File::getFileContents(__DIR__ . '/File/can_be_loaded.txt');
     $this->assertEquals("Yes we can!\n", $contents, 'The contents of the loaded file differ from what was expected');
 }
Esempio n. 2
0
 /**
  * Loads a private key based on the configuration given.
  *
  * @param SAML2_Configuration_PrivateKey $key
  *
  * @return SAML2_Certificate_PrivateKey
  */
 public function loadPrivateKey(SAML2_Configuration_PrivateKey $key)
 {
     $privateKey = SAML2_Utilities_File::getFileContents($key->getFilePath());
     return SAML2_Certificate_PrivateKey::create($privateKey, $key->getPassPhrase());
 }
Esempio n. 3
0
 /**
  * Loads the certificate in the file given
  *
  * @param string $certificateFile the full path to the cert file.
  */
 public function loadCertificateFile($certificateFile)
 {
     $certificate = SAML2_Utilities_File::getFileContents($certificateFile);
     if (!SAML2_Utilities_Certificate::hasValidStructure($certificate)) {
         throw new SAML2_Certificate_Exception_InvalidCertificateStructureException(sprintf('Could not find PEM encoded certificate in "%s"', $certificateFile));
     }
     // capture the certificate contents without the delimiters
     preg_match(SAML2_Utilities_Certificate::CERTIFICATE_PATTERN, $certificate, $matches);
     $this->loadedKeys->add(SAML2_Certificate_X509::createFromCertificateData($matches[1]));
 }