src/Saml.php
public function validateResponse(Response $response, $relayState)
    {
        $this->validateIssuer($response);
        $this->validateDestination($response);

        if ($relayState) {
            $this->validateRelayState($response, $relayState);
        }

        $public = KeyHelper::createPublicKey(
            $this->getMetadata()->getFirstIdpSsoDescriptor()
                ->getFirstKeyDescriptor(KeyDescriptor::USE_SIGNING)
                ->getCertificate()
        );

        if ($this->hasSignature($response)) {
            $this->validateSignature($response, $public);
        }

        if ($response->getAllEncryptedAssertions()) {
            $private = KeyHelper::createPrivateKey($this->getPrivateKey(), null);
            /** @var EncryptedAssertionReader $encryptedAssertion */
            foreach ($response->getAllEncryptedAssertions() as $encryptedAssertion) {
                $assertion = $encryptedAssertion->decryptAssertion($private, new DeserializationContext());

                if ($this->hasSignature($assertion)) {
                    $this->validateSignature($assertion, $public);
                }

                $response->addAssertion($assertion);
            }
        }
    }
public function validateResponse(Response $response, $relayState)
    {
        $this->validateIssuer($response);
        $this->validateDestination($response);

        if ($relayState) {
            $this->validateRelayState($response, $relayState);
        }

        $public = KeyHelper::createPublicKey(
            $this->getMetadata()->getFirstIdpSsoDescriptor()
                ->getFirstKeyDescriptor(KeyDescriptor::USE_SIGNING)
                ->getCertificate()
        );

        if ($this->hasSignature($response)) {
            $this->validateSignature($response, $public);
        }

        if ($response->getAllEncryptedAssertions()) {
            $private = KeyHelper::createPrivateKey($this->getPrivateKey(), null);
            /** @var EncryptedAssertionReader $encryptedAssertion */
            foreach ($response->getAllEncryptedAssertions() as $encryptedAssertion) {
                $assertion = $encryptedAssertion->decryptAssertion($private, new DeserializationContext());

                if ($this->hasSignature($assertion)) {
                    $this->validateSignature($assertion, $public);
                }

                $response->addAssertion($assertion);
            }
        }
    }
public function validateResponse ( Response $ response , $ relayState ) { $ this -> validateIssuer ( $ response ) ; $ this -> validateDestination ( $ response ) ; if ( $ relayState ) { $ this -> validateRelayState ( $ response , $ relayState ) ; } $ public = KeyHelper :: createPublicKey ( $ this -> getMetadata ( ) -> getFirstIdpSsoDescriptor ( ) -> getFirstKeyDescriptor ( KeyDescriptor :: USE_SIGNING ) -> getCertificate ( ) ) ; if ( $ this -> hasSignature ( $ response ) ) { $ this -> validateSignature ( $ response , $ public ) ; } if ( $ response -> getAllEncryptedAssertions ( ) ) { $ private = KeyHelper :: createPrivateKey ( $ this -> getPrivateKey ( ) , null ) ; /** @var EncryptedAssertionReader $encryptedAssertion */ foreach ( $ response -> getAllEncryptedAssertions ( ) as $ encryptedAssertion ) { $ assertion = $ encryptedAssertion -> decryptAssertion ( $ private , new DeserializationContext ( ) ) ; if ( $ this -> hasSignature ( $ assertion ) ) { $ this -> validateSignature ( $ assertion , $ public ) ; } $ response -> addAssertion ( $ assertion ) ; } } }
Validate a IdP Response

@param Response $response
@param          $relayState
Validate a IdP Response