diff options
author | Olav Morken <olav.morken@uninett.no> | 2013-11-15 09:34:07 +0000 |
---|---|---|
committer | Olav Morken <olav.morken@uninett.no> | 2013-11-15 09:34:07 +0000 |
commit | 6f61aef12c6b1b02e32da6d1c696bee6d5f1e4dc (patch) | |
tree | f1d6c78ab5e2eec5f8b8121f9e1a838c28997fa6 /lib/SAML2/XML/md | |
parent | e9c98e008ed7dbb5d642aa4788edd2510c952ca1 (diff) | |
download | simplesamlphp-6f61aef12c6b1b02e32da6d1c696bee6d5f1e4dc.zip simplesamlphp-6f61aef12c6b1b02e32da6d1c696bee6d5f1e4dc.tar.gz simplesamlphp-6f61aef12c6b1b02e32da6d1c696bee6d5f1e4dc.tar.bz2 |
Start using SAML2 library from GitHub.
This patch also starts using Composer for other dependencies
(i.e. php-openid and xmlseclibs).
Thanks to Boy Baukema for implementing this!
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3290 44740490-163a-0410-bde0-09ae8108e29a
Diffstat (limited to 'lib/SAML2/XML/md')
20 files changed, 0 insertions, 2436 deletions
diff --git a/lib/SAML2/XML/md/AdditionalMetadataLocation.php b/lib/SAML2/XML/md/AdditionalMetadataLocation.php deleted file mode 100644 index 3bdb6ba..0000000 --- a/lib/SAML2/XML/md/AdditionalMetadataLocation.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -/** - * Class representing SAML 2 metadata AdditionalMetadataLocation element. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_AdditionalMetadataLocation { - - /** - * The namespace of this metadata. - * - * @var string - */ - public $namespace; - - /** - * The URI where the metadata is located. - * - * @var string - */ - public $location; - - - /** - * Initialize an AdditionalMetadataLocation element. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - - if ($xml === NULL) { - return; - } - - if (!$xml->hasAttribute('namespace')) { - throw new Exception('Missing namespace attribute on AdditionalMetadataLocation element.'); - } - $this->namespace = $xml->getAttribute('namespace'); - - $this->location = $xml->textContent; - } - - - /** - * Convert this AdditionalMetadataLocation to XML. - * - * @param DOMElement $parent The element we should append to. - * @return DOMElement This AdditionalMetadataLocation-element. - */ - public function toXML(DOMElement $parent) { - assert('is_string($this->namespace)'); - assert('is_string($this->location)'); - - $e = SAML2_Utils::addString($parent, SAML2_Const::NS_MD, 'md:AdditionalMetadataLocation', $this->location); - $e->setAttribute('namespace', $this->namespace); - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/AffiliationDescriptor.php b/lib/SAML2/XML/md/AffiliationDescriptor.php deleted file mode 100644 index 927ad1f..0000000 --- a/lib/SAML2/XML/md/AffiliationDescriptor.php +++ /dev/null @@ -1,162 +0,0 @@ -<?php - -/** - * Class representing SAML 2 AffiliationDescriptor element. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_AffiliationDescriptor extends SAML2_SignedElementHelper { - - /** - * The affiliationOwnerID. - * - * @var string - */ - public $affiliationOwnerID; - - - /** - * The ID of this element. - * - * @var string|NULL - */ - public $ID; - - - /** - * How long this element is valid, as a unix timestamp. - * - * @var int|NULL - */ - public $validUntil; - - - /** - * The length of time this element can be cached, as string. - * - * @var string|NULL - */ - public $cacheDuration; - - - /** - * Extensions on this element. - * - * Array of extension elements. - * - * @var array - */ - public $Extensions = array(); - - - /** - * The AffiliateMember(s). - * - * Array of entity ID strings. - * - * @var array - */ - public $AffiliateMember = array(); - - - /** - * KeyDescriptor elements. - * - * Array of SAML2_XML_md_KeyDescriptor elements. - * - * @var array - */ - public $KeyDescriptor = array(); - - - /** - * Initialize a AffiliationDescriptor. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - - parent::__construct($xml); - - if ($xml === NULL) { - return; - } - - if (!$xml->hasAttribute('affiliationOwnerID')) { - throw new Exception('Missing affiliationOwnerID on AffiliationDescriptor.'); - } - $this->affiliationOwnerID = $xml->getAttribute('affiliationOwnerID'); - - if ($xml->hasAttribute('ID')) { - $this->ID = $xml->getAttribute('ID'); - } - - if ($xml->hasAttribute('validUntil')) { - $this->validUntil = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('validUntil')); - } - - if ($xml->hasAttribute('cacheDuration')) { - $this->cacheDuration = $xml->getAttribute('cacheDuration'); - } - - $this->Extensions = SAML2_XML_md_Extensions::getList($xml); - - $this->AffiliateMember = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'AffiliateMember'); - if (empty($this->AffiliateMember)) { - throw new Exception('Missing AffiliateMember in AffiliationDescriptor.'); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:KeyDescriptor') as $kd) { - $this->KeyDescriptor[] = new SAML2_XML_md_KeyDescriptor($kd); - } - } - - - /** - * Add this AffiliationDescriptor to an EntityDescriptor. - * - * @param DOMElement $parent The EntityDescriptor we should append this endpoint to. - * @param string $name The name of the element we should create. - */ - public function toXML(DOMElement $parent) { - assert('is_string($this->affiliationOwnerID)'); - assert('is_null($this->ID) || is_string($this->ID)'); - assert('is_null($this->validUntil) || is_int($this->validUntil)'); - assert('is_null($this->cacheDuration) || is_string($this->cacheDuration)'); - assert('is_array($this->Extensions)'); - assert('is_array($this->AffiliateMember)'); - assert('!empty($this->AffiliateMember)'); - assert('is_array($this->KeyDescriptor)'); - - $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, 'md:AffiliationDescriptor'); - $parent->appendChild($e); - - $e->setAttribute('affiliationOwnerID', $this->affiliationOwnerID); - - if (isset($this->ID)) { - $e->setAttribute('ID', $this->ID); - } - - if (isset($this->validUntil)) { - $e->setAttribute('validUntil', gmdate('Y-m-d\TH:i:s\Z', $this->validUntil)); - } - - if (isset($this->cacheDuration)) { - $e->setAttribute('cacheDuration', $this->cacheDuration); - } - - SAML2_XML_md_Extensions::addList($e, $this->Extensions); - - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:AffiliateMember', FALSE, $this->AffiliateMember); - - foreach ($this->KeyDescriptor as $kd) { - $kd->toXML($e); - } - - $this->signElement($e, $e->firstChild); - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/AttributeAuthorityDescriptor.php b/lib/SAML2/XML/md/AttributeAuthorityDescriptor.php deleted file mode 100644 index 68eefee..0000000 --- a/lib/SAML2/XML/md/AttributeAuthorityDescriptor.php +++ /dev/null @@ -1,128 +0,0 @@ -<?php - -/** - * Class representing SAML 2 metadata AttributeAuthorityDescriptor. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_AttributeAuthorityDescriptor extends SAML2_XML_md_RoleDescriptor { - - /** - * List of AttributeService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $AttributeService = array(); - - - /** - * List of AssertionIDRequestService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $AssertionIDRequestService = array(); - - - /** - * List of supported NameID formats. - * - * Array of strings. - * - * @var array - */ - public $NameIDFormat = array(); - - - /** - * List of supported attribute profiles. - * - * Array with strings. - * - * @var array - */ - public $AttributeProfile = array(); - - - /** - * List of supported attributes. - * - * Array with SAML2_XML_saml_Attribute objects. - * - * @var array - */ - public $Attribute = array(); - - - /** - * Initialize an IDPSSODescriptor. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - parent::__construct('md:AttributeAuthorityDescriptor', $xml); - - if ($xml === NULL) { - return; - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AttributeService') as $ep) { - $this->AttributeService[] = new SAML2_XML_md_EndpointType($ep); - } - if (empty($this->AttributeService)) { - throw new Exception('Must have at least one AttributeService in AttributeAuthorityDescriptor.'); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) { - $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep); - } - - $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat'); - - $this->AttributeProfile = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'AttributeProfile'); - - foreach (SAML2_Utils::xpQuery($xml, './saml_assertion:Attribute') as $a) { - $this->Attribute[] = new SAML2_XML_saml_Attribute($a); - } - } - - - /** - * Add this AttributeAuthorityDescriptor to an EntityDescriptor. - * - * @param DOMElement $parent The EntityDescriptor we should append this IDPSSODescriptor to. - */ - public function toXML(DOMElement $parent) { - assert('is_array($this->AttributeService)'); - assert('!empty($this->AttributeService)'); - assert('is_array($this->AssertionIDRequestService)'); - assert('is_array($this->NameIDFormat)'); - assert('is_array($this->AttributeProfile)'); - assert('is_array($this->Attribute)'); - - $e = parent::toXML($parent); - - foreach ($this->AttributeService as $ep) { - $ep->toXML($e, 'md:AttributeService'); - } - - foreach ($this->AssertionIDRequestService as $ep) { - $ep->toXML($e, 'md:AssertionIDRequestService'); - } - - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat); - - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile); - - foreach ($this->Attribute as $a) { - $a->toXML($e); - } - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/AttributeConsumingService.php b/lib/SAML2/XML/md/AttributeConsumingService.php deleted file mode 100644 index 427fd28..0000000 --- a/lib/SAML2/XML/md/AttributeConsumingService.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php - -/** - * Class representing SAML 2 Metadata AttributeConsumingService element. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_AttributeConsumingService { - - /** - * The index of this AttributeConsumingService. - * - * @var int - */ - public $index; - - - /** - * Whether this is the default AttributeConsumingService. - * - * @var bool|NULL - */ - public $isDefault = NULL; - - - /** - * The ServiceName of this AttributeConsumingService. - * - * This is an associative array with language => translation. - * - * @var array - */ - public $ServiceName = array(); - - - /** - * The ServiceDescription of this AttributeConsumingService. - * - * This is an associative array with language => translation. - * - * @var array - */ - public $ServiceDescription = array(); - - - /** - * The RequestedAttribute elements. - * - * This is an array of SAML_RequestedAttributeType elements. - * - * @var array - */ - public $RequestedAttribute = array(); - - - /** - * Initialize / parse an AttributeConsumingService. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - - if ($xml === NULL) { - return; - } - - - if (!$xml->hasAttribute('index')) { - throw new Exception('Missing index on AttributeConsumingService.'); - } - $this->index = (int)$xml->getAttribute('index'); - - $this->isDefault = SAML2_Utils::parseBoolean($xml, 'isDefault', NULL); - - $this->ServiceName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'ServiceName'); - if (empty($this->ServiceName)) { - throw new Exception('Missing ServiceName in AttributeConsumingService.'); - } - - $this->ServiceDescription = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'ServiceDescription'); - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:RequestedAttribute') as $ra) { - $this->RequestedAttribute[] = new SAML2_XML_md_RequestedAttribute($ra); - } - } - - - /** - * Convert to DOMElement. - * - * @param DOMElement $parent The element we should append this AttributeConsumingService to. - */ - public function toXML(DOMElement $parent) { - assert('is_int($this->index)'); - assert('is_null($this->isDefault) || is_bool($this->isDefault)'); - assert('is_array($this->ServiceName)'); - assert('is_array($this->ServiceDescription)'); - assert('is_array($this->RequestedAttribute)'); - - $doc = $parent->ownerDocument; - - $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:AttributeConsumingService'); - $parent->appendChild($e); - - $e->setAttribute('index', (string)$this->index); - - if ($this->isDefault === TRUE) { - $e->setAttribute('isDefault', 'true'); - } elseif ($this->isDefault === FALSE) { - $e->setAttribute('isDefault', 'false'); - } - - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:ServiceName', TRUE, $this->ServiceName); - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:ServiceDescription', TRUE, $this->ServiceDescription); - - foreach ($this->RequestedAttribute as $ra) { - $ra->toXML($e); - } - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/AuthnAuthorityDescriptor.php b/lib/SAML2/XML/md/AuthnAuthorityDescriptor.php deleted file mode 100644 index 52124ab..0000000 --- a/lib/SAML2/XML/md/AuthnAuthorityDescriptor.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php - -/** - * Class representing SAML 2 metadata AuthnAuthorityDescriptor. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_AuthnAuthorityDescriptor extends SAML2_XML_md_RoleDescriptor { - - /** - * List of AuthnQueryService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $AuthnQueryService = array(); - - - /** - * List of AssertionIDRequestService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $AssertionIDRequestService = array(); - - - /** - * List of supported NameID formats. - * - * Array of strings. - * - * @var array - */ - public $NameIDFormat = array(); - - - /** - * Initialize an IDPSSODescriptor. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - parent::__construct('md:AuthnAuthorityDescriptor', $xml); - - if ($xml === NULL) { - return; - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AuthnQueryService') as $ep) { - $this->AuthnQueryService[] = new SAML2_XML_md_EndpointType($ep); - } - if (empty($this->AuthnQueryService)) { - throw new Exception('Must have at least one AuthnQueryService in AuthnAuthorityDescriptor.'); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) { - $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep); - } - - $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat'); - } - - - /** - * Add this IDPSSODescriptor to an EntityDescriptor. - * - * @param DOMElement $parent The EntityDescriptor we should append this AuthnAuthorityDescriptor to. - */ - public function toXML(DOMElement $parent) { - assert('is_array($this->AuthnQueryService)'); - assert('!empty($this->AuthnQueryService)'); - assert('is_array($this->AssertionIDRequestService)'); - assert('is_array($this->NameIDFormat)'); - - $e = parent::toXML($parent); - - foreach ($this->AuthnQueryService as $ep) { - $ep->toXML($e, 'md:AuthnQueryService'); - } - - foreach ($this->AssertionIDRequestService as $ep) { - $ep->toXML($e, 'md:AssertionIDRequestService'); - } - - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat); - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/ContactPerson.php b/lib/SAML2/XML/md/ContactPerson.php deleted file mode 100644 index ea347c3..0000000 --- a/lib/SAML2/XML/md/ContactPerson.php +++ /dev/null @@ -1,182 +0,0 @@ -<?php - -/** - * Class representing SAML 2 ContactPerson. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_ContactPerson { - - /** - * The contact type. - * - * @var string - */ - public $contactType; - - - /** - * Extensions on this element. - * - * Array of extension elements. - * - * @var array - */ - public $Extensions = array(); - - - /** - * The Company of this contact. - * - * @var string - */ - public $Company = NULL; - - - /** - * The GivenName of this contact. - * - * @var string - */ - public $GivenName = NULL; - - - /** - * The SurName of this contact. - * - * @var string - */ - public $SurName = NULL; - - - /** - * The EmailAddresses of this contact. - * - * @var array - */ - public $EmailAddress = array(); - - - /** - * The TelephoneNumbers of this contact. - * - * @var array - */ - public $TelephoneNumber = array(); - - - /** - * Initialize a ContactPerson element. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - - if ($xml === NULL) { - return; - } - - if (!$xml->hasAttribute('contactType')) { - throw new Exception('Missing contactType on ContactPerson.'); - } - $this->contactType = $xml->getAttribute('contactType'); - - $this->Extensions = SAML2_XML_md_Extensions::getList($xml); - - - $this->Company = self::getStringElement($xml, 'Company'); - $this->GivenName = self::getStringElement($xml, 'GivenName'); - $this->SurName = self::getStringElement($xml, 'SurName'); - $this->EmailAddress = self::getStringElements($xml, 'EmailAddress'); - $this->TelephoneNumber = self::getStringElements($xml, 'TelephoneNumber'); - } - - - /** - * Retrieve the value of a child DOMElements as an array of strings. - * - * @param DOMElement $parent The parent element. - * @param string $name The name of the child elements. - * @return array The value of the child elements. - */ - private static function getStringElements(DOMElement $parent, $name) { - assert('is_string($name)'); - - $e = SAML2_Utils::xpQuery($parent, './saml_metadata:' . $name); - - $ret = array(); - foreach ($e as $i) { - $ret[] = $i->textContent; - } - - return $ret; - } - - - /** - * Retrieve the value of a child DOMElement as a string. - * - * @param DOMElement $parent The parent element. - * @param string $name The name of the child element. - * @return string|NULL The value of the child element. - */ - private static function getStringElement(DOMElement $parent, $name) { - assert('is_string($name)'); - - $e = self::getStringElements($parent, $name); - if (empty($e)) { - return NULL; - } - if (count($e) > 1) { - throw new Exception('More than one ' . $name . ' in ' . $parent->tagName); - } - - return $e[0]; - } - - - /** - * Convert this ContactPerson to XML. - * - * @param DOMElement $parent The element we should add this contact to. - * @return DOMElement The new ContactPerson-element. - */ - public function toXML(DOMElement $parent) { - assert('is_string($this->contactType)'); - assert('is_array($this->Extensions)'); - assert('is_null($this->Company) || is_string($this->Company)'); - assert('is_null($this->GivenName) || is_string($this->GivenName)'); - assert('is_null($this->SurName) || is_string($this->SurName)'); - assert('is_array($this->EmailAddress)'); - assert('is_array($this->TelephoneNumber)'); - - $doc = $parent->ownerDocument; - - $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:ContactPerson'); - $parent->appendChild($e); - - $e->setAttribute('contactType', $this->contactType); - - SAML2_XML_md_Extensions::addList($e, $this->Extensions); - - if (isset($this->Company)) { - SAML2_Utils::addString($e, SAML2_Const::NS_MD, 'md:Company', $this->Company); - } - if (isset($this->GivenName)) { - SAML2_Utils::addString($e, SAML2_Const::NS_MD, 'md:GivenName', $this->GivenName); - } - if (isset($this->SurName)) { - SAML2_Utils::addString($e, SAML2_Const::NS_MD, 'md:SurName', $this->SurName); - } - if (!empty($this->EmailAddress)) { - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:EmailAddress', FALSE, $this->EmailAddress); - } - if (!empty($this->TelephoneNumber)) { - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:TelephoneNumber', FALSE, $this->TelephoneNumber); - } - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/EndpointType.php b/lib/SAML2/XML/md/EndpointType.php deleted file mode 100644 index e4317e6..0000000 --- a/lib/SAML2/XML/md/EndpointType.php +++ /dev/null @@ -1,187 +0,0 @@ -<?php - -/** - * Class representing SAML 2 EndpointType. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_EndpointType { - - /** - * The binding for this endpoint. - * - * @var string - */ - public $Binding; - - - /** - * The URI to this endpoint. - * - * @var string - */ - public $Location; - - - /** - * The URI where responses can be delivered. - * - * @var string|NULL - */ - public $ResponseLocation = NULL; - - - /** - * Extra (namespace qualified) attributes. - * - * @var array - */ - private $attributes = array(); - - - /** - * Initialize an EndpointType. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - - if ($xml === NULL) { - return; - } - - if (!$xml->hasAttribute('Binding')) { - throw new Exception('Missing Binding on ' . $xml->tagName); - } - $this->Binding = $xml->getAttribute('Binding'); - - if (!$xml->hasAttribute('Location')) { - throw new Exception('Missing Location on ' . $xml->tagName); - } - $this->Location = $xml->getAttribute('Location'); - - if ($xml->hasAttribute('ResponseLocation')) { - $this->ResponseLocation = $xml->getAttribute('ResponseLocation'); - } - - foreach ($xml->attributes as $a) { - if ($a->namespaceURI === NULL) { - continue; /* Not namespace-qualified -- skip. */ - } - $fullName = '{' . $a->namespaceURI . '}' . $a->localName; - $this->attributes[$fullName] = array( - 'qualifiedName' => $a->nodeName, - 'namespaceURI' => $a->namespaceURI, - 'value' => $a->value, - ); - } - } - - - /** - * Check if a namespace-qualified attribute exists. - * - * @param string $namespaceURI The namespace URI. - * @param string $localName The local name. - * @return boolean TRUE if the attribute exists, FALSE if not. - */ - public function hasAttributeNS($namespaceURI, $localName) { - assert('is_string($namespaceURI)'); - assert('is_string($localName)'); - - $fullName = '{' . $namespaceURI . '}' . $localName; - return isset($this->attributes[$fullName]); - } - - - /** - * Get a namespace-qualified attribute. - * - * @param string $namespaceURI The namespace URI. - * @param string $localName The local name. - * @return string The value of the attribute, or an empty string if the attribute does not exist. - */ - public function getAttributeNS($namespaceURI, $localName) { - assert('is_string($namespaceURI)'); - assert('is_string($localName)'); - - $fullName = '{' . $namespaceURI . '}' . $localName; - if (!isset($this->attributes[$fullName])) { - return ''; - } - return $this->attributes[$fullName]['value']; - } - - - /** - * Get a namespace-qualified attribute. - * - * @param string $namespaceURI The namespace URI. - * @param string $qualifiedName The local name. - * @param string $value The attribute value. - */ - public function setAttributeNS($namespaceURI, $qualifiedName, $value) { - assert('is_string($namespaceURI)'); - assert('is_string($qualifiedName)'); - - $name = explode(':', $qualifiedName, 2); - if (count($name) < 2) { - throw new Exception('Not a qualified name.'); - } - $localName = $name[1]; - - $fullName = '{' . $namespaceURI . '}' . $localName; - $this->attributes[$fullName] = array( - 'qualifiedName' => $qualifiedName, - 'namespaceURI' => $namespaceURI, - 'value' => $value, - ); - } - - - /** - * Remove a namespace-qualified attribute. - * - * @param string $namespaceURI The namespace URI. - * @param string $localName The local name. - */ - public function removeAttributeNS($namespaceURI, $localName) { - assert('is_string($namespaceURI)'); - assert('is_string($localName)'); - - $fullName = '{' . $namespaceURI . '}' . $localName; - unset($this->attributes[$fullName]); - } - - - /** - * Add this endpoint to an XML element. - * - * @param DOMElement $parent The element we should append this endpoint to. - * @param string $name The name of the element we should create. - */ - public function toXML(DOMElement $parent, $name) { - assert('is_string($name)'); - assert('is_string($this->Binding)'); - assert('is_string($this->Location)'); - assert('is_null($this->ResponseLocation) || is_string($this->ResponseLocation)'); - - $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, $name); - $parent->appendChild($e); - - $e->setAttribute('Binding', $this->Binding); - $e->setAttribute('Location', $this->Location); - - if (isset($this->ResponseLocation)) { - $e->setAttribute('ResponseLocation', $this->ResponseLocation); - } - - foreach ($this->attributes as $a) { - $e->setAttributeNS($a['namespaceURI'], $a['qualifiedName'], $a['value']); - } - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/EntitiesDescriptor.php b/lib/SAML2/XML/md/EntitiesDescriptor.php deleted file mode 100644 index c0e9134..0000000 --- a/lib/SAML2/XML/md/EntitiesDescriptor.php +++ /dev/null @@ -1,147 +0,0 @@ -<?php - -/** - * Class representing SAML 2 EntitiesDescriptor element. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_EntitiesDescriptor extends SAML2_SignedElementHelper { - - /** - * The ID of this element. - * - * @var string|NULL - */ - public $ID; - - - /** - * How long this element is valid, as a unix timestamp. - * - * @var int|NULL - */ - public $validUntil; - - - /** - * The length of time this element can be cached, as string. - * - * @var string|NULL - */ - public $cacheDuration; - - - /** - * The name of this entity collection. - * - * @var string|NULL - */ - public $Name; - - - /** - * Extensions on this element. - * - * Array of extension elements. - * - * @var array - */ - public $Extensions = array(); - - - /** - * Child EntityDescriptor and EntitiesDescriptor elements. - * - * @var array - */ - public $children = array(); - - - /** - * Initialize an EntitiesDescriptor. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - parent::__construct($xml); - - if ($xml === NULL) { - return; - } - - if ($xml->hasAttribute('ID')) { - $this->ID = $xml->getAttribute('ID'); - } - if ($xml->hasAttribute('validUntil')) { - $this->validUntil = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('validUntil')); - } - if ($xml->hasAttribute('cacheDuration')) { - $this->cacheDuration = $xml->getAttribute('cacheDuration'); - } - if ($xml->hasAttribute('Name')) { - $this->Name = $xml->getAttribute('Name'); - } - - $this->Extensions = SAML2_XML_md_Extensions::getList($xml); - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:EntityDescriptor|./saml_metadata:EntitiesDescriptor') as $node) { - if ($node->localName === 'EntityDescriptor') { - $this->children[] = new SAML2_XML_md_EntityDescriptor($node); - } else { - $this->children[] = new SAML2_XML_md_EntitiesDescriptor($node); - } - } - } - - - /** - * Convert this EntitiesDescriptor to XML. - * - * @param DOMElement|NULL $parent The EntitiesDescriptor we should append this EntitiesDescriptor to. - */ - public function toXML(DOMElement $parent = NULL) { - assert('is_null($this->ID) || is_string($this->ID)'); - assert('is_null($this->validUntil) || is_int($this->validUntil)'); - assert('is_null($this->cacheDuration) || is_string($this->cacheDuration)'); - assert('is_null($this->Name) || is_string($this->Name)'); - assert('is_array($this->Extensions)'); - assert('is_array($this->children)'); - - if ($parent === NULL) { - $doc = new DOMDocument(); - $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:EntitiesDescriptor'); - $doc->appendChild($e); - } else { - $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, 'md:EntitiesDescriptor'); - $parent->appendChild($e); - } - - if (isset($this->ID)) { - $e->setAttribute('ID', $this->ID); - } - - if (isset($this->validUntil)) { - $e->setAttribute('validUntil', gmdate('Y-m-d\TH:i:s\Z', $this->validUntil)); - } - - if (isset($this->cacheDuration)) { - $e->setAttribute('cacheDuration', $this->cacheDuration); - } - - if (isset($this->Name)) { - $e->setAttribute('Name', $this->Name); - } - - SAML2_XML_md_Extensions::addList($e, $this->Extensions); - - foreach ($this->children as $node) { - $node->toXML($e); - } - - $this->signElement($e, $e->firstChild); - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/EntityDescriptor.php b/lib/SAML2/XML/md/EntityDescriptor.php deleted file mode 100644 index 89c7dce..0000000 --- a/lib/SAML2/XML/md/EntityDescriptor.php +++ /dev/null @@ -1,252 +0,0 @@ -<?php - -/** - * Class representing SAML 2 EntityDescriptor element. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_EntityDescriptor extends SAML2_SignedElementHelper { - - /** - * The entityID this EntityDescriptor represents. - * - * @var string - */ - public $entityID; - - - /** - * The ID of this element. - * - * @var string|NULL - */ - public $ID; - - - /** - * How long this element is valid, as a unix timestamp. - * - * @var int|NULL - */ - public $validUntil; - - - /** - * The length of time this element can be cached, as string. - * - * @var string|NULL - */ - public $cacheDuration; - - - /** - * Extensions on this element. - * - * Array of extension elements. - * - * @var array - */ - public $Extensions = array(); - - - /** - * Array with all roles for this entity. - * - * Array of SAML2_XML_md_RoleDescriptor objects (and subclasses of RoleDescriptor). - * - * @var array - */ - public $RoleDescriptor = array(); - - - /** - * AffiliationDescriptor of this entity. - * - * @var SAML2_XML_md_AffiliationDescriptor|NULL - */ - public $AffiliationDescriptor = NULL; - - - /** - * Organization of this entity. - * - * @var SAML2_XML_md_Organization|NULL - */ - public $Organization = NULL; - - - /** - * ContactPerson elements for this entity. - * - * @var array - */ - public $ContactPerson = array(); - - - /** - * AdditionalMetadataLocation elements for this entity. - * - * @var array - */ - public $AdditionalMetadataLocation = array(); - - - /** - * Initialize an EntitiyDescriptor. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - parent::__construct($xml); - - if ($xml === NULL) { - return; - } - - if (!$xml->hasAttribute('entityID')) { - throw new Exception('Missing required attribute entityID on EntityDescriptor.'); - } - $this->entityID = $xml->getAttribute('entityID'); - - if ($xml->hasAttribute('ID')) { - $this->ID = $xml->getAttribute('ID'); - } - if ($xml->hasAttribute('validUntil')) { - $this->validUntil = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('validUntil')); - } - if ($xml->hasAttribute('cacheDuration')) { - $this->cacheDuration = $xml->getAttribute('cacheDuration'); - } - - $this->Extensions = SAML2_XML_md_Extensions::getList($xml); - - for ($node = $xml->firstChild; $node !== NULL; $node = $node->nextSibling) { - if (!($node instanceof DOMElement)) { - continue; - } - - if ($node->namespaceURI !== SAML2_Const::NS_MD) { - continue; - } - - switch ($node->localName) { - case 'RoleDescriptor': - $this->RoleDescriptor[] = new SAML2_XML_md_UnknownRoleDescriptor($node); - break; - case 'IDPSSODescriptor': - $this->RoleDescriptor[] = new SAML2_XML_md_IDPSSODescriptor($node); - break; - case 'SPSSODescriptor': - $this->RoleDescriptor[] = new SAML2_XML_md_SPSSODescriptor($node); - break; - case 'AuthnAuthorityDescriptor': - $this->RoleDescriptor[] = new SAML2_XML_md_AuthnAuthorityDescriptor($node); - break; - case 'AttributeAuthorityDescriptor': - $this->RoleDescriptor[] = new SAML2_XML_md_AttributeAuthorityDescriptor($node); - break; - case 'PDPDescriptor': - $this->RoleDescriptor[] = new SAML2_XML_md_PDPDescriptor($node); - break; - } - } - - $affiliationDescriptor = SAML2_Utils::xpQuery($xml, './saml_metadata:AffiliationDescriptor'); - if (count($affiliationDescriptor) > 1) { - throw new Exception('More than one AffiliationDescriptor in the entity.'); - } elseif (!empty($affiliationDescriptor)) { - $this->AffiliationDescriptor = new SAML2_XML_md_AffiliationDescriptor($affiliationDescriptor[0]); - } - - if (empty($this->RoleDescriptor) && is_null($this->AffiliationDescriptor)) { - throw new Exception('Must have either one of the RoleDescriptors or an AffiliationDescriptor in EntityDescriptor.'); - } elseif (!empty($this->RoleDescriptor) && !is_null($this->AffiliationDescriptor)) { - throw new Exception('AffiliationDescriptor cannot be combined with other RoleDescriptor elements in EntityDescriptor.'); - } - - $organization = SAML2_Utils::xpQuery($xml, './saml_metadata:Organization'); - if (count($organization) > 1) { - throw new Exception('More than one Organization in the entity.'); - } elseif (!empty($organization)) { - $this->Organization = new SAML2_XML_md_Organization($organization[0]); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:ContactPerson') as $cp) { - $this->ContactPerson[] = new SAML2_XML_md_ContactPerson($cp); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AdditionalMetadataLocation') as $aml) { - $this->AdditionalMetadataLocation[] = new SAML2_XML_md_AdditionalMetadataLocation($aml); - } - } - - - /** - * Create this EntityDescriptor. - * - * @param DOMElement|NULL $parent The EntitiesDescriptor we should append this EntityDescriptor to. - */ - public function toXML(DOMElement $parent = NULL) { - assert('is_string($this->entityID)'); - assert('is_null($this->ID) || is_string($this->ID)'); - assert('is_null($this->validUntil) || is_int($this->validUntil)'); - assert('is_null($this->cacheDuration) || is_string($this->cacheDuration)'); - assert('is_array($this->Extensions)'); - assert('is_array($this->RoleDescriptor)'); - assert('is_null($this->AffiliationDescriptor) || $this->AffiliationDescriptor instanceof SAML2_XML_md_AffiliationDescriptor'); - assert('is_null($this->Organization) || $this->Organization instanceof SAML2_XML_md_Organization'); - assert('is_array($this->ContactPerson)'); - assert('is_array($this->AdditionalMetadataLocation)'); - - if ($parent === NULL) { - $doc = new DOMDocument(); - $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:EntityDescriptor'); - $doc->appendChild($e); - } else { - $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, 'md:EntityDescriptor'); - $parent->appendChild($e); - } - - $e->setAttribute('entityID', $this->entityID); - - if (isset($this->ID)) { - $e->setAttribute('ID', $this->ID); - } - - if (isset($this->validUntil)) { - $e->setAttribute('validUntil', gmdate('Y-m-d\TH:i:s\Z', $this->validUntil)); - } - - if (isset($this->cacheDuration)) { - $e->setAttribute('cacheDuration', $this->cacheDuration); - } - - SAML2_XML_md_Extensions::addList($e, $this->Extensions); - - foreach ($this->RoleDescriptor as $n) { - $n->toXML($e); - } - - if (isset($this->AffiliationDescriptor)) { - $this->AffiliationDescriptor->toXML($e); - } - - if (isset($this->Organization)) { - $this->Organization->toXML($e); - } - - foreach ($this->ContactPerson as $cp) { - $cp->toXML($e); - } - - foreach ($this->AdditionalMetadataLocation as $n) { - $n->toXML($e); - } - - $this->signElement($e, $e->firstChild); - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/Extensions.php b/lib/SAML2/XML/md/Extensions.php deleted file mode 100644 index 797bdaf..0000000 --- a/lib/SAML2/XML/md/Extensions.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -/** - * Class for handling SAML2 metadata extensions. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_Extensions { - - /** - * Get a list of Extensions in the given element. - * - * @param DOMElement $parent The element that may contain the md:Extensions element. - * @return array Array of extensions. - */ - public static function getList(DOMElement $parent) { - - $ret = array(); - foreach (SAML2_Utils::xpQuery($parent, './saml_metadata:Extensions/*') as $node) { - if ($node->namespaceURI === SAML2_XML_shibmd_Scope::NS && $node->localName === 'Scope') { - $ret[] = new SAML2_XML_shibmd_Scope($node); - } elseif ($node->namespaceURI === SAML2_XML_mdattr_EntityAttributes::NS && $node->localName === 'EntityAttributes') { - $ret[] = new SAML2_XML_mdattr_EntityAttributes($node); - } elseif ($node->namespaceURI === SAML2_XML_mdrpi_Common::NS_MDRPI && $node->localName === 'RegistrationInfo') { - $ret[] = new SAML2_XML_mdrpi_RegistrationInfo($node); - } elseif ($node->namespaceURI === SAML2_XML_mdrpi_Common::NS_MDRPI && $node->localName === 'PublicationInfo') { - $ret[] = new SAML2_XML_mdrpi_PublicationInfo($node); - } elseif ($node->namespaceURI === SAML2_XML_mdui_UIInfo::NS && $node->localName === 'UIInfo') { - $ret[] = new SAML2_XML_mdui_UIInfo($node); - } elseif ($node->namespaceURI === SAML2_XML_mdui_DiscoHints::NS && $node->localName === 'DiscoHints') { - $ret[] = new SAML2_XML_mdui_DiscoHints($node); - } else { - $ret[] = new SAML2_XML_Chunk($node); - } - } - - return $ret; - } - - - /** - * Add a list of Extensions to the given element. - * - * @param DOMElement $parent The element we should add the extensions to. - * @param array $extensions List of extension objects. - */ - public static function addList(DOMElement $parent, array $extensions) { - - if (empty($extensions)) { - return; - } - - $extElement = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, 'md:Extensions'); - $parent->appendChild($extElement); - - foreach ($extensions as $ext) { - $ext->toXML($extElement); - } - } - -} diff --git a/lib/SAML2/XML/md/IDPSSODescriptor.php b/lib/SAML2/XML/md/IDPSSODescriptor.php deleted file mode 100644 index 0479d98..0000000 --- a/lib/SAML2/XML/md/IDPSSODescriptor.php +++ /dev/null @@ -1,145 +0,0 @@ -<?php - -/** - * Class representing SAML 2 IDPSSODescriptor. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_IDPSSODescriptor extends SAML2_XML_md_SSODescriptorType { - - /** - * Whether AuthnRequests sent to this IdP should be signed. - * - * @var bool|NULL - */ - public $WantAuthnRequestsSigned = NULL; - - - /** - * List of SingleSignOnService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $SingleSignOnService = array(); - - - /** - * List of NameIDMappingService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $NameIDMappingService = array(); - - - /** - * List of AssertionIDRequestService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $AssertionIDRequestService = array(); - - - /** - * List of supported attribute profiles. - * - * Array with strings. - * - * @var array - */ - public $AttributeProfile = array(); - - - /** - * List of supported attributes. - * - * Array with SAML2_XML_saml_Attribute objects. - * - * @var array - */ - public $Attribute = array(); - - - /** - * Initialize an IDPSSODescriptor. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - parent::__construct('md:IDPSSODescriptor', $xml); - - if ($xml === NULL) { - return; - } - - $this->WantAuthnRequestsSigned = SAML2_Utils::parseBoolean($xml, 'WantAuthnRequestsSigned', NULL); - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:SingleSignOnService') as $ep) { - $this->SingleSignOnService[] = new SAML2_XML_md_EndpointType($ep); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:NameIDMappingService') as $ep) { - $this->NameIDMappingService[] = new SAML2_XML_md_EndpointType($ep); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) { - $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep); - } - - $this->AttributeProfile = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'AttributeProfile'); - - foreach (SAML2_Utils::xpQuery($xml, './saml_assertion:Attribute') as $a) { - $this->Attribute[] = new SAML2_XML_saml_Attribute($a); - } - } - - - /** - * Add this IDPSSODescriptor to an EntityDescriptor. - * - * @param DOMElement $parent The EntityDescriptor we should append this IDPSSODescriptor to. - */ - public function toXML(DOMElement $parent) { - assert('is_null($this->WantAuthnRequestsSigned) || is_bool($this->WantAuthnRequestsSigned)'); - assert('is_array($this->SingleSignOnService)'); - assert('is_array($this->NameIDMappingService)'); - assert('is_array($this->AssertionIDRequestService)'); - assert('is_array($this->AttributeProfile)'); - assert('is_array($this->Attribute)'); - - $e = parent::toXML($parent); - - if ($this->WantAuthnRequestsSigned === TRUE) { - $e->setAttribute('WantAuthnRequestsSigned', 'true'); - } elseif ($this->WantAuthnRequestsSigned === FALSE) { - $e->setAttribute('WantAuthnRequestsSigned', 'false'); - } - - foreach ($this->SingleSignOnService as $ep) { - $ep->toXML($e, 'md:SingleSignOnService'); - } - - foreach ($this->NameIDMappingService as $ep) { - $ep->toXML($e, 'md:NameIDMappingService'); - } - - foreach ($this->AssertionIDRequestService as $ep) { - $ep->toXML($e, 'md:AssertionIDRequestService'); - } - - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile); - - foreach ($this->Attribute as $a) { - $a->toXML($e); - } - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/IndexedEndpointType.php b/lib/SAML2/XML/md/IndexedEndpointType.php deleted file mode 100644 index c019152..0000000 --- a/lib/SAML2/XML/md/IndexedEndpointType.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php - -/** - * Class representing SAML 2 IndexedEndpointType. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_IndexedEndpointType extends SAML2_XML_md_EndpointType { - - /** - * The index for this endpoint. - * - * @var int - */ - public $index; - - - /** - * Whether this endpoint is the default. - * - * @var bool|NULL - */ - public $isDefault = NULL; - - - /** - * Initialize an IndexedEndpointType. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - parent::__construct($xml); - - if ($xml === NULL) { - return; - } - - if (!$xml->hasAttribute('index')) { - throw new Exception('Missing index on ' . $xml->tagName); - } - $this->index = (int)$xml->getAttribute('index'); - - $this->isDefault = SAML2_Utils::parseBoolean($xml, 'isDefault', NULL); - } - - - /** - * Add this endpoint to an XML element. - * - * @param DOMElement $parent The element we should append this endpoint to. - * @param string $name The name of the element we should create. - */ - public function toXML(DOMElement $parent, $name) { - assert('is_string($name)'); - assert('is_int($this->index)'); - assert('is_null($this->isDefault) || is_bool($this->isDefault)'); - - $e = parent::toXML($parent, $name); - $e->setAttribute('index', (string)$this->index); - - if ($this->isDefault === TRUE) { - $e->setAttribute('isDefault', 'true'); - } elseif ($this->isDefault === FALSE) { - $e->setAttribute('isDefault', 'false'); - } - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/KeyDescriptor.php b/lib/SAML2/XML/md/KeyDescriptor.php deleted file mode 100644 index aeaffe9..0000000 --- a/lib/SAML2/XML/md/KeyDescriptor.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php - -/** - * Class representing a KeyDescriptor element. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_KeyDescriptor { - - /** - * What this key can be used for. - * - * 'encryption', 'signing' or NULL. - * - * @var string|NULL - */ - public $use; - - - /** - * The KeyInfo for this key. - * - * @var SAML2_XML_ds_KeyInfo - */ - public $KeyInfo; - - - /** - * Supported EncryptionMethods. - * - * Array of SAML2_XML_Chunk objects. - * - * @var array - */ - public $EncryptionMethod = array(); - - - /** - * Initialize an KeyDescriptor. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - - if ($xml === NULL) { - return; - } - - if ($xml->hasAttribute('use')) { - $this->use = $xml->getAttribute('use'); - } - - $keyInfo = SAML2_Utils::xpQuery($xml, './ds:KeyInfo'); - if (count($keyInfo) > 1) { - throw new Exception('More than one ds:KeyInfo in the KeyDescriptor.'); - } elseif (empty($keyInfo)) { - throw new Exception('No ds:KeyInfo in the KeyDescriptor.'); - } - $this->KeyInfo = new SAML2_XML_ds_KeyInfo($keyInfo[0]); - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:EncryptionMethod') as $em) { - $this->EncryptionMethod[] = new SAML2_XML_Chunk($em); - } - - } - - - /** - * Convert this KeyDescriptor to XML. - * - * @param DOMElement $parent The element we should append this KeyDescriptor to. - */ - public function toXML(DOMElement $parent) { - assert('is_null($this->use) || is_string($this->use)'); - assert('$this->KeyInfo instanceof SAML2_XML_ds_KeyInfo'); - assert('is_array($this->EncryptionMethod)'); - - $doc = $parent->ownerDocument; - - $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:KeyDescriptor'); - $parent->appendChild($e); - - if (isset($this->use)) { - $e->setAttribute('use', $this->use); - } - - $this->KeyInfo->toXML($e); - - foreach ($this->EncryptionMethod as $em) { - $em->toXML($e); - } - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/Organization.php b/lib/SAML2/XML/md/Organization.php deleted file mode 100644 index 5ceaeed..0000000 --- a/lib/SAML2/XML/md/Organization.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php - -/** - * Class representing SAML 2 Organization element. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_Organization { - - /** - * Extensions on this element. - * - * Array of extension elements. - * - * @var array - */ - public $Extensions = array(); - - - /** - * The OrganizationName, as an array of language => translation. - * - * @var array - */ - public $OrganizationName = array(); - - - /** - * The OrganizationDisplayName, as an array of language => translation. - * - * @var array - */ - public $OrganizationDisplayName = array(); - - - /** - * The OrganizationURL, as an array of language => translation. - * - * @var array - */ - public $OrganizationURL = array(); - - - /** - * Initialize an Organization element. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - - if ($xml === NULL) { - return; - } - - $this->Extensions = SAML2_XML_md_Extensions::getList($xml); - - - $this->OrganizationName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'OrganizationName'); - if (empty($this->OrganizationName)) { - $this->OrganizationName = array('invalid' => ''); - } - - $this->OrganizationDisplayName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'OrganizationDisplayName'); - if (empty($this->OrganizationDisplayName)) { - $this->OrganizationDisplayName = array('invalid' => ''); - } - - $this->OrganizationURL = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'OrganizationURL'); - if (empty($this->OrganizationURL)) { - $this->OrganizationURL = array('invalid' => ''); - } - } - - - /** - * Convert this Organization to XML. - * - * @param DOMElement $parent The element we should add this organization to. - * @return DOMElement This Organization-element. - */ - public function toXML(DOMElement $parent) { - assert('is_array($this->Extensions)'); - assert('is_array($this->OrganizationName)'); - assert('!empty($this->OrganizationName)'); - assert('is_array($this->OrganizationDisplayName)'); - assert('!empty($this->OrganizationDisplayName)'); - assert('is_array($this->OrganizationURL)'); - assert('!empty($this->OrganizationURL)'); - - $doc = $parent->ownerDocument; - - $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:Organization'); - $parent->appendChild($e); - - SAML2_XML_md_Extensions::addList($e, $this->Extensions); - - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:OrganizationName', TRUE, $this->OrganizationName); - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:OrganizationDisplayName', TRUE, $this->OrganizationDisplayName); - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:OrganizationURL', TRUE, $this->OrganizationURL); - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/PDPDescriptor.php b/lib/SAML2/XML/md/PDPDescriptor.php deleted file mode 100644 index f09d054..0000000 --- a/lib/SAML2/XML/md/PDPDescriptor.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php - -/** - * Class representing SAML 2 metadata PDPDescriptor. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_PDPDescriptor extends SAML2_XML_md_RoleDescriptor { - - /** - * List of AuthzService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $AuthzService = array(); - - - /** - * List of AssertionIDRequestService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $AssertionIDRequestService = array(); - - - /** - * List of supported NameID formats. - * - * Array of strings. - * - * @var array - */ - public $NameIDFormat = array(); - - - /** - * Initialize an IDPSSODescriptor. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - parent::__construct('md:PDPDescriptor', $xml); - - if ($xml === NULL) { - return; - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AuthzService') as $ep) { - $this->AuthzService[] = new SAML2_XML_md_EndpointType($ep); - } - if (empty($this->AuthzService)) { - throw new Exception('Must have at least one AuthzService in PDPDescriptor.'); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) { - $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep); - } - - $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat'); - } - - - /** - * Add this PDPDescriptor to an EntityDescriptor. - * - * @param DOMElement $parent The EntityDescriptor we should append this IDPSSODescriptor to. - */ - public function toXML(DOMElement $parent) { - assert('is_array($this->AuthzService)'); - assert('!empty($this->AuthzService)'); - assert('is_array($this->AssertionIDRequestService)'); - assert('is_array($this->NameIDFormat)'); - - $e = parent::toXML($parent); - - foreach ($this->AuthzService as $ep) { - $ep->toXML($e, 'md:AuthzService'); - } - - foreach ($this->AssertionIDRequestService as $ep) { - $ep->toXML($e, 'md:AssertionIDRequestService'); - } - - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat); - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/RequestedAttribute.php b/lib/SAML2/XML/md/RequestedAttribute.php deleted file mode 100644 index 124a25d..0000000 --- a/lib/SAML2/XML/md/RequestedAttribute.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -/** - * Class representing SAML 2 metadata RequestedAttribute. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_RequestedAttribute extends SAML2_XML_saml_Attribute { - - /** - * Whether this attribute is required. - * - * @var bool|NULL - */ - public $isRequired = NULL; - - - /** - * Initialize an RequestedAttribute. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - parent::__construct($xml); - - if ($xml === NULL) { - return; - } - - $this->isRequired = SAML2_Utils::parseBoolean($xml, 'isRequired', NULL); - } - - - /** - * Convert this RequestedAttribute to XML. - * - * @param DOMElement $parent The element we should append this RequestedAttribute to. - */ - public function toXML(DOMElement $parent) { - assert('is_bool($this->isRequired) || is_null($this->isRequired)'); - - $e = $this->toXMLInternal($parent, SAML2_Const::NS_MD, 'md:RequestedAttribute'); - - if ($this->isRequired === TRUE) { - $e->setAttribute('isRequired', 'true'); - } elseif ($this->isRequired === FALSE) { - $e->setAttribute('isRequired', 'false'); - } - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/RoleDescriptor.php b/lib/SAML2/XML/md/RoleDescriptor.php deleted file mode 100644 index 346d34c..0000000 --- a/lib/SAML2/XML/md/RoleDescriptor.php +++ /dev/null @@ -1,208 +0,0 @@ -<?php - -/** - * Class representing SAML 2 RoleDescriptor element. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_RoleDescriptor extends SAML2_SignedElementHelper { - - /** - * The name of this descriptor element. - * - * @var string - */ - private $elementName; - - - /** - * The ID of this element. - * - * @var string|NULL - */ - public $ID; - - - /** - * How long this element is valid, as a unix timestamp. - * - * @var int|NULL - */ - public $validUntil; - - - /** - * The length of time this element can be cached, as string. - * - * @var string|NULL - */ - public $cacheDuration; - - - /** - * List of supported protocols. - * - * @var array - */ - public $protocolSupportEnumeration = array(); - - - /** - * Error URL for this role. - * - * @var string|NULL - */ - public $errorURL; - - - /** - * Extensions on this element. - * - * Array of extension elements. - * - * @var array - */ - public $Extensions = array(); - - - /** - * KeyDescriptor elements. - * - * Array of SAML2_XML_md_KeyDescriptor elements. - * - * @var array - */ - public $KeyDescriptor = array(); - - - /** - * Organization of this role. - * - * @var SAML2_XML_md_Organization|NULL - */ - public $Organization = NULL; - - - /** - * ContactPerson elements for this role. - * - * Array of SAML2_XML_md_ContactPerson objects. - * - * @var array - */ - public $ContactPerson = array(); - - - /** - * Initialize a RoleDescriptor. - * - * @param string $elementName The name of this element. - * @param DOMElement|NULL $xml The XML element we should load. - */ - protected function __construct($elementName, DOMElement $xml = NULL) { - assert('is_string($elementName)'); - - parent::__construct($xml); - $this->elementName = $elementName; - - if ($xml === NULL) { - return; - } - - if ($xml->hasAttribute('ID')) { - $this->ID = $xml->getAttribute('ID'); - } - if ($xml->hasAttribute('validUntil')) { - $this->validUntil = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('validUntil')); - } - if ($xml->hasAttribute('cacheDuration')) { - $this->cacheDuration = $xml->getAttribute('cacheDuration'); - } - - if (!$xml->hasAttribute('protocolSupportEnumeration')) { - throw new Exception('Missing protocolSupportEnumeration attribute on ' . $xml->localName); - } - $this->protocolSupportEnumeration = preg_split('/[\s]+/', $xml->getAttribute('protocolSupportEnumeration')); - - if ($xml->hasAttribute('errorURL')) { - $this->errorURL = $xml->getAttribute('errorURL'); - } - - - $this->Extensions = SAML2_XML_md_Extensions::getList($xml); - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:KeyDescriptor') as $kd) { - $this->KeyDescriptor[] = new SAML2_XML_md_KeyDescriptor($kd); - } - - $organization = SAML2_Utils::xpQuery($xml, './saml_metadata:Organization'); - if (count($organization) > 1) { - throw new Exception('More than one Organization in the entity.'); - } elseif (!empty($organization)) { - $this->Organization = new SAML2_XML_md_Organization($organization[0]); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:ContactPerson') as $cp) { - $this->contactPersons[] = new SAML2_XML_md_ContactPerson($cp); - } - } - - - /** - * Add this RoleDescriptor to an EntityDescriptor. - * - * @param DOMElement $parent The EntityDescriptor we should append this endpoint to. - * @param string $name The name of the element we should create. - */ - protected function toXML(DOMElement $parent) { - assert('is_null($this->ID) || is_string($this->ID)'); - assert('is_null($this->validUntil) || is_int($this->validUntil)'); - assert('is_null($this->cacheDuration) || is_string($this->cacheDuration)'); - assert('is_array($this->protocolSupportEnumeration)'); - assert('is_null($this->errorURL) || is_string($this->errorURL)'); - assert('is_array($this->Extensions)'); - assert('is_array($this->KeyDescriptor)'); - assert('is_null($this->Organization) || $this->Organization instanceof SAML2_XML_md_Organization'); - assert('is_array($this->ContactPerson)'); - - $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, $this->elementName); - $parent->appendChild($e); - - if (isset($this->ID)) { - $e->setAttribute('ID', $this->ID); - } - - if (isset($this->validUntil)) { - $e->setAttribute('validUntil', gmdate('Y-m-d\TH:i:s\Z', $this->validUntil)); - } - - if (isset($this->cacheDuration)) { - $e->setAttribute('cacheDuration', $this->cacheDuration); - } - - $e->setAttribute('protocolSupportEnumeration', implode(' ', $this->protocolSupportEnumeration)); - - if (isset($this->errorURL)) { - $e->setAttribute('errorURL', $this->errorURL); - } - - - SAML2_XML_md_Extensions::addList($e, $this->Extensions); - - foreach ($this->KeyDescriptor as $kd) { - $kd->toXML($e); - } - - if (isset($this->Organization)) { - $this->Organization->toXML($e); - } - - foreach ($this->ContactPerson as $cp) { - $cp->toXML($e); - } - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/SPSSODescriptor.php b/lib/SAML2/XML/md/SPSSODescriptor.php deleted file mode 100644 index da7077e..0000000 --- a/lib/SAML2/XML/md/SPSSODescriptor.php +++ /dev/null @@ -1,107 +0,0 @@ -<?php - -/** - * Class representing SAML 2 SPSSODescriptor. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_SPSSODescriptor extends SAML2_XML_md_SSODescriptorType { - - /** - * Whether this SP signs authentication requests. - * - * @var bool|NULL - */ - public $AuthnRequestsSigned = NULL; - - - /** - * Whether this SP wants the Assertion elements to be signed. - * - * @var bool|NULL - */ - public $WantAssertionsSigned = NULL; - - - /** - * List of AssertionConsumerService endpoints for this SP. - * - * Array with IndexedEndpointType objects. - * - * @var array - */ - public $AssertionConsumerService = array(); - - - /** - * List of AttributeConsumingService descriptors for this SP. - * - * Array with SAML2_XML_md_AttribteConsumingService objects. - * - * @var array - */ - public $AttributeConsumingService = array(); - - - /** - * Initialize a SPSSODescriptor. - * - * @param DOMElement|NULL $xml The XML element we should load. - */ - public function __construct(DOMElement $xml = NULL) { - parent::__construct('md:SPSSODescriptor', $xml); - - if ($xml === NULL) { - return; - } - - $this->AuthnRequestsSigned = SAML2_Utils::parseBoolean($xml, 'AuthnRequestsSigned', NULL); - $this->WantAssertionsSigned = SAML2_Utils::parseBoolean($xml, 'WantAssertionsSigned', NULL); - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AssertionConsumerService') as $ep) { - $this->AssertionConsumerService[] = new SAML2_XML_md_IndexedEndpointType($ep); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AttributeConsumingService') as $acs) { - $this->AttributeConsumingService[] = new SAML2_XML_md_AttributeConsumingService($acs); - } - } - - - /** - * Add this SPSSODescriptor to an EntityDescriptor. - * - * @param DOMElement $parent The EntityDescriptor we should append this SPSSODescriptor to. - */ - public function toXML(DOMElement $parent) { - assert('is_null($this->AuthnRequestsSigned) || is_bool($this->AuthnRequestsSigned)'); - assert('is_null($this->WantAssertionsSigned) || is_bool($this->WantAssertionsSigned)'); - assert('is_array($this->AssertionConsumerService)'); - assert('is_array($this->AttributeConsumingService)'); - - $e = parent::toXML($parent); - - if ($this->AuthnRequestsSigned === TRUE) { - $e->setAttribute('AuthnRequestsSigned', 'true'); - } elseif ($this->AuthnRequestsSigned === FALSE) { - $e->setAttribute('AuthnRequestsSigned', 'false'); - } - - if ($this->WantAssertionsSigned === TRUE) { - $e->setAttribute('WantAssertionsSigned', 'true'); - } elseif ($this->WantAssertionsSigned === FALSE) { - $e->setAttribute('WantAssertionsSigned', 'false'); - } - - - foreach ($this->AssertionConsumerService as $ep) { - $ep->toXML($e, 'md:AssertionConsumerService'); - } - - foreach ($this->AttributeConsumingService as $acs) { - $acs->toXML($e); - } - } - -} diff --git a/lib/SAML2/XML/md/SSODescriptorType.php b/lib/SAML2/XML/md/SSODescriptorType.php deleted file mode 100644 index bdb8e96..0000000 --- a/lib/SAML2/XML/md/SSODescriptorType.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php - -/** - * Class representing SAML 2 SSODescriptorType. - * - * @package simpleSAMLphp - * @version $Id$ - */ -abstract class SAML2_XML_md_SSODescriptorType extends SAML2_XML_md_RoleDescriptor { - - /** - * List of ArtifactResolutionService endpoints. - * - * Array with IndexedEndpointType objects. - * - * @var array - */ - public $ArtifactResolutionService = array(); - - - /** - * List of SingleLogoutService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $SingleLogoutService = array(); - - - /** - * List of ManageNameIDService endpoints. - * - * Array with EndpointType objects. - * - * @var array - */ - public $ManageNameIDService = array(); - - - /** - * List of supported NameID formats. - * - * Array of strings. - * - * @var array - */ - public $NameIDFormat = array(); - - - /** - * Initialize a SSODescriptor. - * - * @param string $elementName The name of this element. - * @param DOMElement|NULL $xml The XML element we should load. - */ - protected function __construct($elementName, DOMElement $xml = NULL) { - assert('is_string($elementName)'); - - parent::__construct($elementName, $xml); - - if ($xml === NULL) { - return; - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:ArtifactResolutionService') as $ep) { - $this->ArtifactResolutionService[] = new SAML2_XML_md_IndexedEndpointType($ep); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:SingleLogoutService') as $ep) { - $this->SingleLogoutService[] = new SAML2_XML_md_EndpointType($ep); - } - - foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:ManageNameIDService') as $ep) { - $this->ManageNameIDService[] = new SAML2_XML_md_EndpointType($ep); - } - - $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat'); - } - - - /** - * Add this SSODescriptorType to an EntityDescriptor. - * - * @param DOMElement $parent The EntityDescriptor we should append this SSODescriptorType to. - * @param string $name The name of the element we should create. - * @return DOMElement The generated SSODescriptor DOMElement. - */ - protected function toXML(DOMElement $parent) { - assert('is_array($this->ArtifactResolutionService)'); - assert('is_array($this->SingleLogoutService)'); - assert('is_array($this->ManageNameIDService)'); - assert('is_array($this->NameIDFormat)'); - - $e = parent::toXML($parent); - - foreach ($this->ArtifactResolutionService as $ep) { - $ep->toXML($e, 'md:ArtifactResolutionService'); - } - - foreach ($this->SingleLogoutService as $ep) { - $ep->toXML($e, 'md:SingleLogoutService'); - } - - foreach ($this->ManageNameIDService as $ep) { - $ep->toXML($e, 'md:ManageNameIDService'); - } - - SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat); - - return $e; - } - -} diff --git a/lib/SAML2/XML/md/UnknownRoleDescriptor.php b/lib/SAML2/XML/md/UnknownRoleDescriptor.php deleted file mode 100644 index 66e3a79..0000000 --- a/lib/SAML2/XML/md/UnknownRoleDescriptor.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -/** - * Class representing unknown RoleDescriptors. - * - * @package simpleSAMLphp - * @version $Id$ - */ -class SAML2_XML_md_UnknownRoleDescriptor extends SAML2_XML_md_RoleDescriptor { - - /** - * This RoleDescriptor as XML - * - * @var SAML2_XML_Chunk - */ - private $xml; - - - /** - * Initialize an unknown RoleDescriptor. - * - * @param DOMElement $xml The XML element we should load. - */ - public function __construct(DOMElement $xml) { - parent::__construct('md:RoleDescriptor', $xml); - - $this->xml = new SAML2_XML_Chunk($xml); - } - - - /** - * Add this RoleDescriptor to an EntityDescriptor. - * - * @param DOMElement $parent The EntityDescriptor we should append this RoleDescriptor to. - */ - public function toXML(DOMElement $parent) { - - $this->xml->toXML($parent); - } - -} |