You are here

SAML2_Response.php in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

File

src/SAML2_Response.php
View source
<?php

/**
 * This file is part of miniOrange SAML plugin.
 *
 * miniOrange SAML plugin is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * miniOrange SAML plugin is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with miniOrange SAML plugin.  If not, see <http://www.gnu.org/licenses/>.
 */
namespace Drupal\miniorange_saml;

use DOMElement;

/**
 * Class for SAML2 Response messages.
 *
 */
class SAML2_Response {

  /* The assertions in this response. */
  private $assertions;

  /* The destination URL in this response. */
  private $destination;
  private $certificates;
  private $signatureData;

  /**
   * Constructor for SAML 2 response messages.
   *
   * @param DOMElement|NULL $xml The input message.
   */
  public function __construct(DOMElement $xml = NULL) {

    //parent::__construct('Response', $xml);
    $this->assertions = array();
    $this->certificates = array();
    if ($xml === NULL) {
      return;
    }
    $sig = Utilities::validateElement($xml);
    if ($sig !== FALSE) {
      $this->certificates = $sig['Certificates'];
      $this->signatureData = $sig;
    }

    /* set the destination from saml response */
    if ($xml
      ->hasAttribute('Destination')) {
      $this->destination = $xml
        ->getAttribute('Destination');
    }
    for ($node = $xml->firstChild; $node !== NULL; $node = $node->nextSibling) {
      if ($node->namespaceURI !== 'urn:oasis:names:tc:SAML:2.0:assertion') {
        continue;
      }
      if ($node->localName === 'Assertion' || $node->localName === 'EncryptedAssertion') {
        $this->assertions[] = new SAML2_Assertion($node);
      }
    }
  }

  /**
   * Retrieve the assertions in this response.
   *
   * @return SAML2_Assertion[]|SAML2_EncryptedAssertion[]
   */
  public function getAssertions() {
    return $this->assertions;
  }
  public function getDestination() {
    return $this->destination;
  }
  public function getSignatureData() {
    return $this->signatureData;
  }

}

Classes

Namesort descending Description
SAML2_Response Class for SAML2 Response messages.