public function isValid($retrieveParametersFromServer = false)
    {
        $this->_error = null;
        try {
            $dom = new DOMDocument();
            $dom = OneLogin_Saml2_Utils::loadXML($dom, $this->_logoutRequest);

            $idpData = $this->_settings->getIdPData();
            $idPEntityId = $idpData['entityId'];

            if ($this->_settings->isStrict()) {
                $security = $this->_settings->getSecurityData();

                if ($security['wantXMLValidation']) {
                    $res = OneLogin_Saml2_Utils::validateXML($dom, 'saml-schema-protocol-2.0.xsd', $this->_settings->isDebugActive());
                    if (!$res instanceof DOMDocument) {
                        throw new OneLogin_Saml2_ValidationError(
                            "Invalid SAML Logout Request. Not match the saml-schema-protocol-2.0.xsd",
                            OneLogin_Saml2_ValidationError::INVALID_XML_FORMAT
                        );
                    }
                }

                $currentURL = OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery();

                // Check NotOnOrAfter
                if ($dom->documentElement->hasAttribute('NotOnOrAfter')) {
                    $na = OneLogin_Saml2_Utils::parseSAML2Time($dom->documentElement->getAttribute('NotOnOrAfter'));
                    if ($na <= time()) {
                        throw new OneLogin_Saml2_ValidationError(
                            "Could not validate timestamp: expired. Check system clock.",
                            OneLogin_Saml2_ValidationError::RESPONSE_EXPIRED
                        );
                    }
                }

                // Check destination
                if ($dom->documentElement->hasAttribute('Destination')) {
                    $destination = $dom->documentElement->getAttribute('Destination');
                    if (!empty($destination) && strpos($destination, $currentURL) === false) {
                        throw new OneLogin_Saml2_ValidationError(
                            "The LogoutRequest was received at $currentURL instead of $destination",
                            OneLogin_Saml2_ValidationError::WRONG_DESTINATION
                        );
                    }
                }

                $nameId = static::getNameId($dom, $this->_settings->getSPkey());

                // Check issuer
                $issuer = static::getIssuer($dom);
                if (!empty($issuer) && $issuer != $idPEntityId) {
                    throw new OneLogin_Saml2_ValidationError(
                        "Invalid issuer in the Logout Request",
                        OneLogin_Saml2_ValidationError::WRONG_ISSUER
                    );
                }

                if ($security['wantMessagesSigned'] && !isset($_GET['Signature'])) {
                    throw new OneLogin_Saml2_ValidationError(
                        "The Message of the Logout Request is not signed and the SP require it",
                        OneLogin_Saml2_ValidationError::NO_SIGNED_MESSAGE
                    );
                }
            }

            if (isset($_GET['Signature'])) {
                $signatureValid = OneLogin_Saml2_Utils::validateBinarySign("SAMLRequest", $_GET, $idpData, $retrieveParametersFromServer);
                if (!$signatureValid) {
                    throw new OneLogin_Saml2_ValidationError(
                        "Signature validation failed. Logout Request rejected",
                        OneLogin_Saml2_ValidationError::INVALID_SIGNATURE
                    );
                }
            }

            return true;
        } catch (Exception $e) {
            $this->_error = $e->getMessage();
            $debug = $this->_settings->isDebugActive();
            if ($debug) {
                echo htmlentities($this->_error);
            }
            return false;
        }
    }
public function isValid($retrieveParametersFromServer = false)
    {
        $this->_error = null;
        try {
            $dom = new DOMDocument();
            $dom = OneLogin_Saml2_Utils::loadXML($dom, $this->_logoutRequest);

            $idpData = $this->_settings->getIdPData();
            $idPEntityId = $idpData['entityId'];

            if ($this->_settings->isStrict()) {
                $security = $this->_settings->getSecurityData();

                if ($security['wantXMLValidation']) {
                    $res = OneLogin_Saml2_Utils::validateXML($dom, 'saml-schema-protocol-2.0.xsd', $this->_settings->isDebugActive());
                    if (!$res instanceof DOMDocument) {
                        throw new OneLogin_Saml2_ValidationError(
                            "Invalid SAML Logout Request. Not match the saml-schema-protocol-2.0.xsd",
                            OneLogin_Saml2_ValidationError::INVALID_XML_FORMAT
                        );
                    }
                }

                $currentURL = OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery();

                // Check NotOnOrAfter
                if ($dom->documentElement->hasAttribute('NotOnOrAfter')) {
                    $na = OneLogin_Saml2_Utils::parseSAML2Time($dom->documentElement->getAttribute('NotOnOrAfter'));
                    if ($na <= time()) {
                        throw new OneLogin_Saml2_ValidationError(
                            "Could not validate timestamp: expired. Check system clock.",
                            OneLogin_Saml2_ValidationError::RESPONSE_EXPIRED
                        );
                    }
                }

                // Check destination
                if ($dom->documentElement->hasAttribute('Destination')) {
                    $destination = $dom->documentElement->getAttribute('Destination');
                    if (!empty($destination) && strpos($destination, $currentURL) === false) {
                        throw new OneLogin_Saml2_ValidationError(
                            "The LogoutRequest was received at $currentURL instead of $destination",
                            OneLogin_Saml2_ValidationError::WRONG_DESTINATION
                        );
                    }
                }

                $nameId = static::getNameId($dom, $this->_settings->getSPkey());

                // Check issuer
                $issuer = static::getIssuer($dom);
                if (!empty($issuer) && $issuer != $idPEntityId) {
                    throw new OneLogin_Saml2_ValidationError(
                        "Invalid issuer in the Logout Request",
                        OneLogin_Saml2_ValidationError::WRONG_ISSUER
                    );
                }

                if ($security['wantMessagesSigned'] && !isset($_GET['Signature'])) {
                    throw new OneLogin_Saml2_ValidationError(
                        "The Message of the Logout Request is not signed and the SP require it",
                        OneLogin_Saml2_ValidationError::NO_SIGNED_MESSAGE
                    );
                }
            }

            if (isset($_GET['Signature'])) {
                $signatureValid = OneLogin_Saml2_Utils::validateBinarySign("SAMLRequest", $_GET, $idpData, $retrieveParametersFromServer);
                if (!$signatureValid) {
                    throw new OneLogin_Saml2_ValidationError(
                        "Signature validation failed. Logout Request rejected",
                        OneLogin_Saml2_ValidationError::INVALID_SIGNATURE
                    );
                }
            }

            return true;
        } catch (Exception $e) {
            $this->_error = $e->getMessage();
            $debug = $this->_settings->isDebugActive();
            if ($debug) {
                echo htmlentities($this->_error);
            }
            return false;
        }
    }
public function isValid ( $ retrieveParametersFromServer = false ) { $ this -> _error = null ; try { $ dom = new DOMDocument ( ) ; $ dom = OneLogin_Saml2_Utils :: loadXML ( $ dom , $ this -> _logoutRequest ) ; $ idpData = $ this -> _settings -> getIdPData ( ) ; $ idPEntityId = $ idpData [ 'entityId' ] ; if ( $ this -> _settings -> isStrict ( ) ) { $ security = $ this -> _settings -> getSecurityData ( ) ; if ( $ security [ 'wantXMLValidation' ] ) { $ res = OneLogin_Saml2_Utils :: validateXML ( $ dom , 'saml-schema-protocol-2.0.xsd' , $ this -> _settings -> isDebugActive ( ) ) ; if ( ! $ res instanceof DOMDocument ) { throw new OneLogin_Saml2_ValidationError ( "Invalid SAML Logout Request. Not match the saml-schema-protocol-2.0.xsd" , OneLogin_Saml2_ValidationError :: INVALID_XML_FORMAT ) ; } } $ currentURL = OneLogin_Saml2_Utils :: getSelfRoutedURLNoQuery ( ) ; // Check NotOnOrAfter if ( $ dom -> documentElement -> hasAttribute ( 'NotOnOrAfter' ) ) { $ na = OneLogin_Saml2_Utils :: parseSAML2Time ( $ dom -> documentElement -> getAttribute ( 'NotOnOrAfter' ) ) ; if ( $ na <= time ( ) ) { throw new OneLogin_Saml2_ValidationError ( "Could not validate timestamp: expired. Check system clock." , OneLogin_Saml2_ValidationError :: RESPONSE_EXPIRED ) ; } } // Check destination if ( $ dom -> documentElement -> hasAttribute ( 'Destination' ) ) { $ destination = $ dom -> documentElement -> getAttribute ( 'Destination' ) ; if ( ! empty ( $ destination ) && strpos ( $ destination , $ currentURL ) === false ) { throw new OneLogin_Saml2_ValidationError ( "The LogoutRequest was received at $currentURL instead of $destination" , OneLogin_Saml2_ValidationError :: WRONG_DESTINATION ) ; } } $ nameId = static :: getNameId ( $ dom , $ this -> _settings -> getSPkey ( ) ) ; // Check issuer $ issuer = static :: getIssuer ( $ dom ) ; if ( ! empty ( $ issuer ) && $ issuer != $ idPEntityId ) { throw new OneLogin_Saml2_ValidationError ( "Invalid issuer in the Logout Request" , OneLogin_Saml2_ValidationError :: WRONG_ISSUER ) ; } if ( $ security [ 'wantMessagesSigned' ] && ! isset ( $ _GET [ 'Signature' ] ) ) { throw new OneLogin_Saml2_ValidationError ( "The Message of the Logout Request is not signed and the SP require it" , OneLogin_Saml2_ValidationError :: NO_SIGNED_MESSAGE ) ; } } if ( isset ( $ _GET [ 'Signature' ] ) ) { $ signatureValid = OneLogin_Saml2_Utils :: validateBinarySign ( "SAMLRequest" , $ _GET , $ idpData , $ retrieveParametersFromServer ) ; if ( ! $ signatureValid ) { throw new OneLogin_Saml2_ValidationError ( "Signature validation failed. Logout Request rejected" , OneLogin_Saml2_ValidationError :: INVALID_SIGNATURE ) ; } } return true ; } catch ( Exception $ e ) { $ this -> _error = $ e -> getMessage ( ) ; $ debug = $ this -> _settings -> isDebugActive ( ) ; if ( $ debug ) { echo htmlentities ( $ this -> _error ) ; } return false ; } }
Checks if the Logout Request recieved is valid.

@param bool $retrieveParametersFromServer

@return bool If the Logout Request is or not valid
Checks if the Logout Request recieved is valid .