Skip to content
Snippets Groups Projects
Commit db331199 authored by Olav Morken's avatar Olav Morken
Browse files

SAML2: Add mdrpi:PublicationInfo extension.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2946 44740490-163a-0410-bde0-09ae8108e29a
parent 97c4e7b6
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,8 @@ class SAML2_XML_md_Extensions { ...@@ -22,6 +22,8 @@ class SAML2_XML_md_Extensions {
$ret[] = new SAML2_XML_shibmd_Scope($node); $ret[] = new SAML2_XML_shibmd_Scope($node);
} elseif ($node->namespaceURI === SAML2_XML_mdattr_EntityAttributes::NS && $node->localName === 'EntityAttributes') { } elseif ($node->namespaceURI === SAML2_XML_mdattr_EntityAttributes::NS && $node->localName === 'EntityAttributes') {
$ret[] = new SAML2_XML_mdattr_EntityAttributes($node); $ret[] = new SAML2_XML_mdattr_EntityAttributes($node);
} elseif ($node->namespaceURL === SAML2_XML_mdrpi_Common::NS_MDRPI && $node->localName === 'PublicationInfo') {
$ret[] = new SAML2_XML_mdrpi_PublicationInfo($node);
} else { } else {
$ret[] = new SAML2_XML_Chunk($node); $ret[] = new SAML2_XML_Chunk($node);
} }
......
<?php
/**
* Common definitions for the mdrpi metadata extension.
*
* @link: http://docs.oasis-open.org/security/saml/Post2.0/saml-metadata-rpi/v1.0/saml-metadata-rpi-v1.0.pdf
* @package simpleSAMLphp
* @version $Id$
*/
class SAML2_XML_mdrpi_Common {
const NS_MDRPI = 'urn:oasis:names:tc:SAML:metadata:rpi';
}
<?php
/**
* Class for handling the mdrpi:PublicationInfo element.
*
* @link: http://docs.oasis-open.org/security/saml/Post2.0/saml-metadata-rpi/v1.0/saml-metadata-rpi-v1.0.pdf
* @package simpleSAMLphp
* @version $Id$
*/
class SAML2_XML_mdrpi_PublicationInfo {
/**
* The identifier of the metadata publisher.
*
* @var string
*/
public $publisher;
/**
* The creation timestamp for the metadata, as a UNIX timestamp.
*
* @var int|NULL
*/
public $creationInstant;
/**
* Identifier for this metadata publication.
*
* @var string|NULL
*/
public $publicationId;
/**
* Link to usage policy for this metadata.
*
* This is an associative array with language=>URL.
*
* @var array
*/
public $UsagePolicy = array();
/**
* Create/parse a mdrpi:PublicationInfo element.
*
* @param DOMElement|NULL $xml The XML element we should load.
*/
public function __construct(DOMElement $xml = NULL) {
if ($xml === NULL) {
return;
}
if (!$xml->hasAttribute('publisher')) {
throw new Exception('Missing required attribute "publisher" in mdrpi:PublicationInfo element.');
}
$this->publisher = $xml->getAttribute('publisher');
if ($xml->hasAttribute('creationInstant')) {
$this->creationInstant = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('creationInstant'));
}
if ($xml->hasAttribute('publicationId')) {
$this->publicationId = $xml->getAttribute('publicationId');
}
$query = './*[local-name()="UsagePolicy" and namespace-uri()="' . SAML2_XML_mdrpi_Common::NS_MDRPI . '"]';
$this->UsagePolicy = SAML2_Utils::extractLocalizedStrings($xml, $query);
}
/**
* Convert this element to XML.
*
* @param DOMElement $parent The element we should append to.
*/
public function toXML(DOMElement $parent) {
assert('is_string($this->publisher)');
assert('is_int($this->creationInstant) || is_null($this->creationInstant)');
assert('is_string($this->publicationId) || is_null($this->publicationId)');
assert('is_array($this->UsagePolicy)');
$doc = $parent->ownerDocument;
$e = $doc->createElementNS(SAML2_XML_mdrpi_Common::NS_MDRPI, 'mdrpi:PublicationInfo');
$parent->appendChild($e);
$e->setAttribute('publisher', $this->publisher);
if ($this->creationInstant !== NULL) {
$e->setAttribute('creationInstant', gmdate('Y-m-d\TH:i:s\Z', $this->creationInstant));
}
if ($this->publicationId !== NULL) {
$e->setAttribute('publicationId', $this->publicationId);
}
SAML2_Utils::addStrings($e, SAML2_XML_mdrpi_Common::NS_MDRPI, 'mdrpi:UsagePolicy', TRUE, $this->UsagePolicy);
return $e;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment