Пример #1
0
 /**
  * Add a key to the collection
  *
  * @param SAML2_Certificate_Key $key
  */
 public function add($key)
 {
     if (!$key instanceof SAML2_Certificate_Key) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('SAML2_Certificate_Key', $key);
     }
     parent::add($key);
 }
Пример #2
0
 /**
  * @param string $destination
  */
 public function __construct($destination)
 {
     if (!is_string($destination)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $destination);
     }
     $this->destination = $destination;
 }
Пример #3
0
 /**
  * @param string $fingerPrint
  */
 public function __construct($fingerPrint)
 {
     if (!is_string($fingerPrint)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $fingerPrint);
     }
     $this->contents = $fingerPrint;
 }
Пример #4
0
 /**
  * Attempts to load a key based on the given certificateData
  *
  * @param string $certificateData
  */
 public function loadCertificateData($certificateData)
 {
     if (!is_string($certificateData)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $certificateData);
     }
     $this->loadedKeys->add(SAML2_Certificate_X509::createFromCertificateData($certificateData));
 }
Пример #5
0
 /**
  * @param $message
  */
 public function addError($message)
 {
     if (!is_string($message)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $message);
     }
     $this->errors[] = $message;
 }
Пример #6
0
 /**
  * Add a key to the collection
  *
  * @param SAML2_Certificate_Fingerprint $fingerprint
  */
 public function add($fingerprint)
 {
     if (!$fingerprint instanceof SAML2_Certificate_Fingerprint) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('SAML2_Certificate_Fingerprint ', $fingerprint);
     }
     parent::add($fingerprint);
 }
Пример #7
0
 public static function create($keyContents, $passphrase = NULL)
 {
     if (!is_string($keyContents)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $keyContents);
     }
     if ($passphrase && !is_string($passphrase)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $passphrase);
     }
     $keyData = array('PEM' => $keyContents, self::USAGE_ENCRYPTION => TRUE);
     if ($passphrase) {
         $keyData['passphrase'] = $passphrase;
     }
     return new self($keyData);
 }
Пример #8
0
 /**
  * @param string $file full absolute path to the file
  *
  * @return string
  */
 public static function getFileContents($file)
 {
     if (!is_string($file)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $file);
     }
     if (!is_readable($file)) {
         throw new SAML2_Exception_RuntimeException(sprintf('File "%s" does not exist or is not readable', $file));
     }
     $contents = file_get_contents($file);
     if ($contents === FALSE) {
         throw new SAML2_Exception_RuntimeException(sprintf('Could not read from existing and readable file "%s"', $file));
     }
     return $contents;
 }
Пример #9
0
 public function __construct($filePath, $name, $passphrase = NULL)
 {
     if (!is_string($filePath)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $filePath);
     }
     if (!is_string($name)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $name);
     }
     if ($passphrase && !is_string($passphrase)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $passphrase);
     }
     $this->filePath = $filePath;
     $this->passphrase = $passphrase;
     $this->name = $name;
 }
Пример #10
0
 /**
  * Loads the fingerprints from a configurationValue
  *
  * @param SAML2_Configuration_CertificateProvider $configuration
  *
  * @return SAML2_Certificate_FingerprintCollection
  */
 public function loadFingerprints(SAML2_Configuration_CertificateProvider $configuration)
 {
     $fingerprints = $configuration->getCertificateFingerprints();
     if (!is_array($fingerprints) && !$fingerprints instanceof \Traversable) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('array or instanceof \\Traversable', $fingerprints);
     }
     $collection = new SAML2_Certificate_FingerprintCollection();
     foreach ($fingerprints as $fingerprint) {
         if (!is_string($fingerprint) && !(is_object($fingerprint) && method_exists($fingerprint, '__toString'))) {
             throw SAML2_Exception_InvalidArgumentException::invalidType('fingerprint as string or object that can be casted to string', $fingerprint);
         }
         $collection->add(new SAML2_Certificate_Fingerprint((string) $fingerprint));
     }
     return $collection;
 }
Пример #11
0
 /**
  * @param $file
  *
  * @return DOMDocument
  */
 public static function fromFile($file)
 {
     if (!is_string($file)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $file);
     }
     if (!is_file($file)) {
         throw new SAML2_Exception_InvalidArgumentException(sprintf('Path "%s" is not a file', $file));
     }
     if (!is_readable($file)) {
         throw new SAML2_Exception_InvalidArgumentException(sprintf('File "%s" is not readable', $file));
     }
     // libxml_disable_entity_loader(true) disables DOMDocument::load() method
     // so we need to read the content and use DOMDocument::loadXML()
     $xml = file_get_contents($file);
     if ($xml === FALSE) {
         throw new SAML2_Exception_RuntimeException(sprintf('Contents of readable file "%s" could not be gotten', $file));
     }
     if (trim($xml) === '') {
         throw new SAML2_Exception_RuntimeException(sprintf('File "%s" does not have content', $file));
     }
     return static::fromString($xml);
 }
Пример #12
0
 /**
  * Asserts that the parameter is of type string
  * @param mixed $test
  *
  * @throws Exception
  */
 protected function assertIsString($test)
 {
     if (!is_string($test)) {
         throw SAML2_Exception_InvalidArgumentException::invalidType('string', $test);
     }
 }