ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SubjectConfirmation.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2\XML\saml;
4
7
14{
20 public $Method;
21
27 public $NameID;
28
35
42 public function __construct(\DOMElement $xml = null)
43 {
44 if ($xml === null) {
45 return;
46 }
47
48 if (!$xml->hasAttribute('Method')) {
49 throw new \Exception('SubjectConfirmation element without Method attribute.');
50 }
51 $this->Method = $xml->getAttribute('Method');
52
53 $nid = Utils::xpQuery($xml, './saml_assertion:NameID');
54 if (count($nid) > 1) {
55 throw new \Exception('More than one NameID in a SubjectConfirmation element.');
56 } elseif (!empty($nid)) {
57 $this->NameID = new NameID($nid[0]);
58 }
59
60 $scd = Utils::xpQuery($xml, './saml_assertion:SubjectConfirmationData');
61 if (count($scd) > 1) {
62 throw new \Exception('More than one SubjectConfirmationData child in a SubjectConfirmation element.');
63 } elseif (!empty($scd)) {
65 }
66 }
67
74 public function toXML(\DOMElement $parent)
75 {
76 assert(is_string($this->Method));
77 assert(is_null($this->NameID) || $this->NameID instanceof NameID);
78 assert(is_null($this->SubjectConfirmationData) || $this->SubjectConfirmationData instanceof SubjectConfirmationData);
79
80 $e = $parent->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:SubjectConfirmation');
81 $parent->appendChild($e);
82
83 $e->setAttribute('Method', $this->Method);
84
85 if (isset($this->NameID)) {
86 $this->NameID->toXML($e);
87 }
88 if (isset($this->SubjectConfirmationData)) {
89 $this->SubjectConfirmationData->toXML($e);
90 }
91
92 return $e;
93 }
94}
$sc Method
$sc SubjectConfirmationData
An exception for terminatinating execution or to throw for unit testing.
const NS_SAML
The namespace for the SAML 2 assertions.
Definition: Constants.php:220
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
Definition: Utils.php:191
toXML(\DOMElement $parent)
Convert this element to XML.
__construct(\DOMElement $xml=null)
Initialize (and parse? a SubjectConfirmation element.
$xml
Definition: metadata.php:240