summaryrefslogtreecommitdiffstats
path: root/lib/SAML2/XML/md/AdditionalMetadataLocation.php
blob: 3bdb6ba72354877bc177ca4a289f8b6b2a7a0d70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?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;
	}

}