ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SubjectConfirmationData.php
Go to the documentation of this file.
1 <?php
2 
3 namespace SAML2\XML\saml;
4 
7 use SAML2\Utils;
10 
17 {
23  public $NotBefore;
24 
30  public $NotOnOrAfter;
31 
37  public $Recipient;
38 
44  public $InResponseTo;
45 
51  public $Address;
52 
61  public $info = array();
62 
68  public function __construct(\DOMElement $xml = null)
69  {
70  if ($xml === null) {
71  return;
72  }
73 
74  if ($xml->hasAttribute('NotBefore')) {
75  $this->NotBefore = Utils::xsDateTimeToTimestamp($xml->getAttribute('NotBefore'));
76  }
77  if ($xml->hasAttribute('NotOnOrAfter')) {
78  $this->NotOnOrAfter = Utils::xsDateTimeToTimestamp($xml->getAttribute('NotOnOrAfter'));
79  }
80  if ($xml->hasAttribute('Recipient')) {
81  $this->Recipient = $xml->getAttribute('Recipient');
82  }
83  if ($xml->hasAttribute('InResponseTo')) {
84  $this->InResponseTo = $xml->getAttribute('InResponseTo');
85  }
86  if ($xml->hasAttribute('Address')) {
87  $this->Address = $xml->getAttribute('Address');
88  }
89  for ($n = $xml->firstChild; $n !== null; $n = $n->nextSibling) {
90  if (!($n instanceof \DOMElement)) {
91  continue;
92  }
93  if ($n->namespaceURI !== XMLSecurityDSig::XMLDSIGNS) {
94  $this->info[] = new Chunk($n);
95  continue;
96  }
97  switch ($n->localName) {
98  case 'KeyInfo':
99  $this->info[] = new KeyInfo($n);
100  break;
101  default:
102  $this->info[] = new Chunk($n);
103  break;
104  }
105  }
106  }
107 
114  public function toXML(\DOMElement $parent)
115  {
116  assert(is_null($this->NotBefore) || is_int($this->NotBefore));
117  assert(is_null($this->NotOnOrAfter) || is_int($this->NotOnOrAfter));
118  assert(is_null($this->Recipient) || is_string($this->Recipient));
119  assert(is_null($this->InResponseTo) || is_string($this->InResponseTo));
120  assert(is_null($this->Address) || is_string($this->Address));
121 
122  $e = $parent->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:SubjectConfirmationData');
123  $parent->appendChild($e);
124 
125  if (isset($this->NotBefore)) {
126  $e->setAttribute('NotBefore', gmdate('Y-m-d\TH:i:s\Z', $this->NotBefore));
127  }
128  if (isset($this->NotOnOrAfter)) {
129  $e->setAttribute('NotOnOrAfter', gmdate('Y-m-d\TH:i:s\Z', $this->NotOnOrAfter));
130  }
131  if (isset($this->Recipient)) {
132  $e->setAttribute('Recipient', $this->Recipient);
133  }
134  if (isset($this->InResponseTo)) {
135  $e->setAttribute('InResponseTo', $this->InResponseTo);
136  }
137  if (isset($this->Address)) {
138  $e->setAttribute('Address', $this->Address);
139  }
141  foreach ($this->info as $n) {
142  $n->toXML($e);
143  }
144 
145  return $e;
146  }
147 }
$sc SubjectConfirmationData InResponseTo
$sc SubjectConfirmationData Recipient
$xml
Definition: metadata.php:240
__construct(\DOMElement $xml=null)
Initialize (and parse) a SubjectConfirmationData element.
$n
Definition: RandomTest.php:85
Create styles array
The data for the language used.
static xsDateTimeToTimestamp($time)
This function converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(.s+)?Z to a UNIX timestamp...
Definition: Utils.php:721
$sc SubjectConfirmationData NotOnOrAfter
const NS_SAML
The namespace for the SAML 2 assertions.
Definition: Constants.php:220