You are here

private function SAML2_Assertion::addSubject in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 7

Add a Subject-node to the assertion.

Parameters

DOMElement $root The assertion element we should add the subject to.:

1 call to SAML2_Assertion::addSubject()
SAML2_Assertion::toXML in includes/Assertion.php
Convert this assertion to an XML element.

File

includes/Assertion.php, line 1126

Class

SAML2_Assertion

Code

private function addSubject(DOMElement $root) {
  if ($this->nameId === NULL && $this->encryptedNameId === NULL) {

    /* We don't have anything to create a Subject node for. */
    return;
  }
  $subject = $root->ownerDocument
    ->createElementNS('urn:oasis:names:tc:SAML:2.0:assertion', 'saml:Subject');
  $root
    ->appendChild($subject);
  if ($this->encryptedNameId === NULL) {
    Utilities::addNameId($subject, $this->nameId);
  }
  else {
    $eid = $subject->ownerDocument
      ->createElementNS('urn:oasis:names:tc:SAML:2.0:assertion', 'saml:' . 'EncryptedID');
    $subject
      ->appendChild($eid);
    $eid
      ->appendChild($subject->ownerDocument
      ->importNode($this->encryptedNameId, TRUE));
  }
  foreach ($this->SubjectConfirmation as $sc) {
    $sc
      ->toXML($subject);
  }
}