summaryrefslogtreecommitdiffstats
path: root/lib/SAML2/ArtifactResponse.php
blob: e8186826d371563fd73b571372197403d800b129 (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
63
64
65
66
67
68
69
70
71
<?php

/**
 * The SAML2_ArtifactResponse, is the response to the SAML2_ArtifactResolve.
 *
 * @author Danny Bollaert, UGent AS. <danny.bollaert@ugent.be>
 * @package simpleSAMLphp
 * @version $Id$
 */
class SAML2_ArtifactResponse extends SAML2_StatusResponse {


	/**
	 * The DOMElement with the message the artifact refers
	 * to, or NULL if we don't refer to any artifact.
	 *
	 * @var DOMElement|NULL
	 */
	private $any;


	public function __construct(DOMElement $xml = NULL) {
		parent::__construct('ArtifactResponse', $xml);

		if(!is_null($xml)){

			$status = SAML2_Utils::xpQuery($xml, './saml_protocol:Status');
			assert('!empty($status)'); /* Will have failed during StatusResponse parsing. */

			$status = $status[0];

			for ($any = $status->nextSibling; $any !== NULL; $any = $any->nextSibling) {
				if ($any instanceof DOMElement) {
					$this->any = $any;
					break;
				}
				/* Ignore comments and text nodes. */
			}
		}

	}


	public function setAny(DOMElement $any = NULL) {
		$this->any = $any;
	}


	public function getAny() {
		return $this->any;
	}


	/**
	 * Convert the response message to an XML element.
	 *
	 * @return DOMElement  This response.
	 */
	public function toUnsignedXML() {

		$root = parent::toUnsignedXML();
		if (isset($this->any)) {
			$node = $root->ownerDocument->importNode($this->any, TRUE);
			$root->appendChild($node);

		}

		return $root;
	}

}