コード例 #1
0
 /**
  * @param int|string $notOnOrAfter
  * @throws \InvalidArgumentException
  */
 public function setNotOnOrAfter($notOnOrAfter)
 {
     if (is_string($notOnOrAfter)) {
         $notOnOrAfter = Helper::parseSAMLTime($notOnOrAfter);
     }
     if (!is_int($notOnOrAfter) || $notOnOrAfter < 1) {
         throw new \InvalidArgumentException();
     }
     $this->notOnOrAfter = $notOnOrAfter;
 }
コード例 #2
0
 /**
  * @param int|string $authnInstant
  * @throws \InvalidArgumentException
  */
 public function setAuthnInstant($authnInstant)
 {
     if (is_string($authnInstant)) {
         $authnInstant = Helper::parseSAMLTime($authnInstant);
     } else {
         if (!is_int($authnInstant) || $authnInstant < 1) {
             throw new \InvalidArgumentException('Invalid AuthnInstant');
         }
     }
     $this->authnInstant = $authnInstant;
 }
コード例 #3
0
ファイル: Message.php プロジェクト: pmaglione/lightsaml
 /**
  * @param \DOMElement $xml
  * @throws \AerialShip\LightSaml\Error\InvalidXmlException
  */
 public function loadFromXml(\DOMElement $xml)
 {
     $name = $this->getXmlNodeLocalName();
     if (($pos = strpos($name, ':')) !== false) {
         $name = substr($name, $pos + 1);
     }
     if ($xml->localName != $name) {
         throw new InvalidXmlException('Expected ' . $this->getXmlNodeLocalName() . ' node but got ' . $xml->localName);
     }
     if ($this->getXmlNodeNamespace() && $xml->namespaceURI != $this->getXmlNodeNamespace()) {
         throw new InvalidXmlException('Expected ' . $this->getXmlNodeNamespace() . ' namespace but got' . $xml->namespaceURI);
     }
     $this->checkRequiredAttributes($xml, array('ID', 'Version', 'IssueInstant'));
     $this->setID($xml->getAttribute('ID'));
     $this->setVersion($xml->getAttribute('Version'));
     $this->setIssueInstant(Helper::parseSAMLTime($xml->getAttribute('IssueInstant')));
     $this->setDestination($xml->getAttribute('Destination'));
     $this->iterateChildrenElements($xml, function (\DOMElement $node) {
         if ($node->localName == 'Issuer' && $node->namespaceURI == Protocol::NS_ASSERTION) {
             $this->setIssuer($node->textContent);
         }
     });
 }
コード例 #4
0
 /**
  * @param \DOMElement $xml
  * @throws \AerialShip\LightSaml\Error\InvalidXmlException
  */
 function loadFromXml(\DOMElement $xml)
 {
     if ($xml->localName != 'EntitiesDescriptor' || $xml->namespaceURI != Protocol::NS_METADATA) {
         throw new InvalidXmlException('Expected EntitiesDescriptor element and ' . Protocol::NS_METADATA . ' namespace but got ' . $xml->localName);
     }
     if ($xml->hasAttribute('validUntil')) {
         $this->setValidUntil(Helper::parseSAMLTime($xml->getAttribute('validUntil')));
     }
     if ($xml->hasAttribute('cacheDuration')) {
         $this->setCacheDuration($xml->getAttribute('cacheDuration'));
     }
     if ($xml->hasAttribute('ID')) {
         $this->setId($xml->getAttribute('ID'));
     }
     if ($xml->hasAttribute('Name')) {
         $this->setName($xml->getAttribute('Name'));
     }
     $this->items = array();
     $this->loadXmlChildren($xml, array(array('node' => array('name' => 'EntitiesDescriptor', 'ns' => Protocol::NS_METADATA), 'class' => '\\AerialShip\\LightSaml\\Model\\Metadata\\EntitiesDescriptor'), array('node' => array('name' => 'EntityDescriptor', 'ns' => Protocol::NS_METADATA), 'class' => '\\AerialShip\\LightSaml\\Model\\Metadata\\EntityDescriptor')), function (LoadFromXmlInterface $obj) {
         $this->addItem($obj);
     });
     if (empty($this->items)) {
         throw new InvalidXmlException('Expected at least one of EntityDescriptor or EntitiesDescriptor');
     }
 }