public function __construct(\DOMElement $xml = null)
{
$this->id = Utils::getContainer()->generateId();
$this->issueInstant = Temporal::getTime();
$this->issuer = '';
$this->authnInstant = Temporal::getTime();
$this->attributes = array();
$this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
$this->certificates = array();
$this->AuthenticatingAuthority = array();
$this->SubjectConfirmation = array();
if ($xml === null) {
return;
}
if (!$xml->hasAttribute('ID')) {
throw new \Exception('Missing ID attribute on SAML assertion.');
}
$this->id = $xml->getAttribute('ID');
if ($xml->getAttribute('Version') !== '2.0') {
/* Currently a very strict check. */
throw new \Exception('Unsupported version: ' . $xml->getAttribute('Version'));
}
$this->issueInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('IssueInstant'));
$issuer = Utils::xpQuery($xml, './saml_assertion:Issuer');
if (empty($issuer)) {
throw new \Exception('Missing <saml:Issuer> in assertion.');
}
$this->issuer = new XML\saml\Issuer($issuer[0]);
if ($this->issuer->Format === Constants::NAMEID_ENTITY) {
$this->issuer = $this->issuer->value;
}
$this->parseSubject($xml);
$this->parseConditions($xml);
$this->parseAuthnStatement($xml);
$this->parseAttributes($xml);
$this->parseEncryptedAttributes($xml);
$this->parseSignature($xml);
}