/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:AuthnStatement'); $parent->appendChild($result); $result->setAttribute('AuthnInstant', Helper::time2string($this->getAuthnInstant())); if ($this->getSessionIndex()) { $result->setAttribute('SessionIndex', $this->getSessionIndex()); } $authnContextNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:AuthnContext'); $result->appendChild($authnContextNode); $refNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:AuthnContextClassRef', $this->getAuthnContext()); $authnContextNode->appendChild($refNode); return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:SubjectConfirmationData'); $parent->appendChild($result); if ($this->getNotBefore()) { $result->setAttribute('NotBefore', Helper::time2string($this->getNotBefore())); } if ($this->getNotOnOrAfter()) { $result->setAttribute('NotOnOrAfter', Helper::time2string($this->getNotOnOrAfter())); } foreach (array('Recipient', 'InResponseTo', 'Address') as $name) { $method = "get{$name}"; if ($this->{$method}()) { $result->setAttribute($name, $this->{$method}()); } } return $result; }
function getXml(\DOMNode $parent, SerializationContext $context) { $result = parent::getXml($parent, $context); if ($this->getNotOnOrAfter()) { $result->setAttribute('NotOnOrAfter', Helper::time2string($this->getNotOnOrAfter())); } if ($this->getReason()) { $result->setAttribute('Reason', $this->getReason()); } if ($this->getNameID()) { $result->appendChild($this->getNameID()->getXml($parent, $context)); } if ($this->getSessionIndex()) { $sessionIndex = $context->getDocument()->createElementNS(Protocol::SAML2, 'samlp:SessionIndex', $this->getSessionIndex()); $result->appendChild($sessionIndex); } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ public function getXml(\DOMNode $parent, SerializationContext $context) { $this->prepareForXml(); if ($this->getXmlNodeNamespace()) { $result = $context->getDocument()->createElementNS($this->getXmlNodeNamespace(), $this->getXmlNodeLocalName()); } else { $result = $context->getDocument()->createElement($this->getXmlNodeLocalName()); } $parent->appendChild($result); $result->setAttribute('ID', $this->getID()); $result->setAttribute('Version', $this->getVersion()); $result->setAttribute('IssueInstant', Helper::time2string($this->getIssueInstant())); if ($this->getDestination()) { $result->setAttribute('Destination', $this->getDestination()); } $issuerNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:Issuer', $this->getIssuer()); $result->appendChild($issuerNode); return $result; }
/** * @param \DOMNode $parent * @param SerializationContext $context * @throws \RuntimeException * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_METADATA, 'md:EntitiesDescriptor'); $parent->appendChild($result); if ($this->getValidUntil()) { $result->setAttribute('validUntil', Helper::time2string($this->getValidUntil())); } if ($this->getCacheDuration()) { $result->setAttribute('cacheDuration', $this->getCacheDuration()); } if ($this->getId()) { $result->setAttribute('ID', $this->getId()); } if ($this->getName()) { $result->setAttribute('Name', $this->getName()); } if ($signature = $this->getSignature()) { if ($signature instanceof SignatureCreator) { $signature->getXml($result, $context); } else { throw new \RuntimeException('Signature must be SignatureCreator'); } } foreach ($this->items as $item) { $item->getXml($result, $context); } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @throws \AerialShip\LightSaml\Error\InvalidAssertionException * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $this->prepareForXml(); $result = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:Assertion'); $parent->appendChild($result); $result->setAttribute('ID', $this->getID()); $result->setAttribute('Version', $this->getVersion()); $result->setAttribute('IssueInstant', Helper::time2string($this->getIssueInstant())); $issuerNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:Issuer', $this->getIssuer()); $result->appendChild($issuerNode); $this->getSubject()->getXml($result, $context); $conditionsNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:Conditions'); $result->appendChild($conditionsNode); $conditionsNode->setAttribute('NotBefore', Helper::time2string($this->getNotBefore())); $conditionsNode->setAttribute('NotOnOrAfter', Helper::time2string($this->getNotOnOrAfter())); if ($this->getValidAudience()) { $audienceRestrictionNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'AudienceRestriction'); $conditionsNode->appendChild($audienceRestrictionNode); foreach ($this->getValidAudience() as $v) { $audienceNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'Audience', $v); $audienceRestrictionNode->appendChild($audienceNode); } } $attributeStatementNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:AttributeStatement'); $result->appendChild($attributeStatementNode); foreach ($this->getAllAttributes() as $attribute) { $attribute->getXml($attributeStatementNode, $context); } $this->getAuthnStatement()->getXml($result, $context); if ($signature = $this->getSignature()) { if (!$signature instanceof SignatureCreator) { throw new InvalidAssertionException('Signature must be SignatureCreator'); } $signature->getXml($result, $context); } return $result; }