public function validateMetadata($xml)
    {
        assert('is_string($xml)');

        $errors = array();
        $res = OneLogin_Saml2_Utils::validateXML($xml, 'saml-schema-metadata-2.0.xsd', $this->_debug);
        if (!$res instanceof DOMDocument) {
            $errors[] = $res;
        } else {
            $dom = $res;
            $element = $dom->documentElement;
            if ($element->tagName !== 'md:EntityDescriptor') {
                $errors[] = 'noEntityDescriptor_xml';
            } else {
                $validUntil = $cacheDuration = $expireTime = null;

                if ($element->hasAttribute('validUntil')) {
                    $validUntil = OneLogin_Saml2_Utils::parseSAML2Time($element->getAttribute('validUntil'));
                }
                if ($element->hasAttribute('cacheDuration')) {
                    $cacheDuration = $element->getAttribute('cacheDuration');
                }

                $expireTime = OneLogin_Saml2_Utils::getExpireTime($cacheDuration, $validUntil);
                if (isset($expireTime) && time() > $expireTime) {
                    $errors[] = 'expired_xml';
                }
            }
        }

        // TODO: Support Metadata Sign Validation

        return $errors;
    }
public function validateMetadata($xml)
    {
        assert('is_string($xml)');

        $errors = array();
        $res = OneLogin_Saml2_Utils::validateXML($xml, 'saml-schema-metadata-2.0.xsd', $this->_debug);
        if (!$res instanceof DOMDocument) {
            $errors[] = $res;
        } else {
            $dom = $res;
            $element = $dom->documentElement;
            if ($element->tagName !== 'md:EntityDescriptor') {
                $errors[] = 'noEntityDescriptor_xml';
            } else {
                $validUntil = $cacheDuration = $expireTime = null;

                if ($element->hasAttribute('validUntil')) {
                    $validUntil = OneLogin_Saml2_Utils::parseSAML2Time($element->getAttribute('validUntil'));
                }
                if ($element->hasAttribute('cacheDuration')) {
                    $cacheDuration = $element->getAttribute('cacheDuration');
                }

                $expireTime = OneLogin_Saml2_Utils::getExpireTime($cacheDuration, $validUntil);
                if (isset($expireTime) && time() > $expireTime) {
                    $errors[] = 'expired_xml';
                }
            }
        }

        // TODO: Support Metadata Sign Validation

        return $errors;
    }
public function validateMetadata ( $ xml ) { assert ( 'is_string($xml)' ) ; $ errors = array ( ) ; $ res = OneLogin_Saml2_Utils :: validateXML ( $ xml , 'saml-schema-metadata-2.0.xsd' , $ this -> _debug ) ; if ( ! $ res instanceof DOMDocument ) { $ errors [ ] = $ res ; } else { $ dom = $ res ; $ element = $ dom -> documentElement ; if ( $ element -> tagName !== 'md:EntityDescriptor' ) { $ errors [ ] = 'noEntityDescriptor_xml' ; } else { $ validUntil = $ cacheDuration = $ expireTime = null ; if ( $ element -> hasAttribute ( 'validUntil' ) ) { $ validUntil = OneLogin_Saml2_Utils :: parseSAML2Time ( $ element -> getAttribute ( 'validUntil' ) ) ; } if ( $ element -> hasAttribute ( 'cacheDuration' ) ) { $ cacheDuration = $ element -> getAttribute ( 'cacheDuration' ) ; } $ expireTime = OneLogin_Saml2_Utils :: getExpireTime ( $ cacheDuration , $ validUntil ) ; if ( isset ( $ expireTime ) && time ( ) > $ expireTime ) { $ errors [ ] = 'expired_xml' ; } } } // TODO: Support Metadata Sign Validation return $ errors ; }
Validates an XML SP Metadata.

@param string $xml Metadata's XML that will be validate

@return Array The list of found errors

@throws Exception
Validates an XML SP Metadata .