OneLogin_Saml2_Response::__construct PHP Method

__construct() public method

Constructs the SAML Response object.
public __construct ( OneLogin_Saml2_Settings $settings, string $response )
$settings OneLogin_Saml2_Settings Settings.
$response string A UUEncoded SAML response from the IdP.
    public function __construct(OneLogin_Saml2_Settings $settings, $response)
    {
        $this->_settings = $settings;
        $baseURL = $this->_settings->getBaseURL();
        if (!empty($baseURL)) {
            OneLogin_Saml2_Utils::setBaseURL($baseURL);
        }
        $this->response = base64_decode($response);
        $this->document = new DOMDocument();
        $this->document = OneLogin_Saml2_Utils::loadXML($this->document, $this->response);
        if (!$this->document) {
            throw new Exception('SAML Response could not be processed');
        }
        // Quick check for the presence of EncryptedAssertion
        $encryptedAssertionNodes = $this->document->getElementsByTagName('EncryptedAssertion');
        if ($encryptedAssertionNodes->length !== 0) {
            $this->decryptedDocument = clone $this->document;
            $this->encrypted = true;
            $this->decryptedDocument = $this->_decryptAssertion($this->decryptedDocument);
        }
    }

Usage Example

示例#1
0
 /**
  * Constructor that process the SAML Response,
  * Internally initializes an SP SAML instance
  * and an OneLogin_Saml2_Response.
  *
  * @param OneLogin_Saml_Settings $oldSettings Settings
  * @param string                 $$assertion  SAML Response
  */
 public function __construct($oldSettings, $assertion)
 {
     $auth = new OneLogin_Saml2_Auth($oldSettings);
     $settings = $auth->getSettings();
     parent::__construct($settings, $assertion);
 }