/**
  * {@inheritdoc}
  * @see \Saml\Ecp\Response\Validator\ValidatorInterface::isValid()
  */
 public function isValid(ResponseInterface $response)
 {
     $valid = false;
     try {
         $soapMessage = $response->getSoapMessage();
     } catch (\Exception $e) {
         $this->addMessage(sprintf("Error loading SOAP message: [%s] %s", get_class($e), $e->getMessage()));
         return $valid;
     }
     $elements = $soapMessage->getHeaderElements();
     $invalidAttributes = 0;
     foreach ($elements as $element) {
         /* @var $element \DomElement */
         foreach ($this->_requiredAttributeValues as $name => $value) {
             $attributeValue = $element->getAttributeNS($this->_soapEnvelopeNamespaceUri, $name);
             if ($attributeValue != $value) {
                 $this->addMessage(sprintf("Header element '%s' has attribute '%s' with wrong value '%s', expected '%s'", $element->nodeName, $name, $attributeValue, $value));
                 $invalidAttributes++;
             }
         }
     }
     if (!$invalidAttributes) {
         $valid = true;
     }
     return $valid;
 }
 /**
  * {@inheritdoc}
  * @see \Saml\Ecp\Response\Validator\ValidatorInterface::isValid()
  */
 public function isValid(ResponseInterface $response)
 {
     $soapMessage = $response->getSoapMessage();
     if ($soapMessage->isFault()) {
         $this->addMessage(sprintf("Fault SOAP response: [%s] %s (%s)", $soapMessage->getFaultCode(), $soapMessage->getFaultString(), $soapMessage->getFaultDetail()));
         return false;
     }
     return true;
 }
 /**
  * {@inheritdoc}
  * @see \Saml\Ecp\Response\Validator\ValidatorInterface::isValid()
  */
 public function isValid(ResponseInterface $response)
 {
     $expectedStatus = $this->getOption(self::OPT_EXPECTED_STATUS, $this->_defaultExpectedStatus);
     $status = $response->getHttpResponse()->getStatusCode();
     if ($status != $expectedStatus) {
         $this->addMessage(sprintf("HTTP status code %d is different from the expected %d", $status, $expectedStatus));
         return false;
     }
     return true;
 }
 /**
  * {@inheritdoc}
  * @see \Saml\Ecp\Response\Validator\ValidatorInterface::isValid()
  */
 public function isValid(ResponseInterface $response)
 {
     $partial = $this->getOption(self::OPT_PARTIAL);
     $expectedContentType = $this->getOption(self::OPT_EXPECTED_CONTENT_TYPE);
     if (null === $expectedContentType) {
         throw new GeneralException\MissingOptionException(self::OPT_EXPECTED_CONTENT_TYPE);
     }
     $contentType = $response->getHttpResponse()->getHeaders()->get('Content-Type')->getFieldValue();
     if ($partial) {
         $parts = explode(';', $contentType);
         if ($parts[0] != $expectedContentType) {
             $this->addMessage(sprintf("Content type '%s' is different from the expected '%s' (partial comparison)", $contentType, $expectedContentType));
             return false;
         }
     } else {
         if ($contentType != $expectedContentType) {
             $this->addMessage(sprintf("Content type '%s' is different from the expected '%s'", $contentType, $expectedContentType));
             return false;
         }
     }
     return true;
 }
 /**
  * {@inheritdoc}
  * @see \Saml\Ecp\Response\Validator\ValidatorInterface::isValid()
  */
 public function isValid(ResponseInterface $response)
 {
     $valid = false;
     $schemaFile = $this->getOption(self::OPT_SOAP_ENVELOPE_XSD);
     if (null === $schemaFile) {
         throw new GeneralException\MissingOptionException(self::OPT_SOAP_ENVELOPE_XSD);
     }
     if (!file_exists($schemaFile)) {
         throw new GeneralException\FileNotFoundException($schemaFile);
     }
     if (!is_file($schemaFile)) {
         throw new GeneralException\InvalidFileException(sprintf("Invalid file: '%s'", $schemaFile));
     }
     if (!is_readable($schemaFile)) {
         throw new GeneralException\InvalidFileException(sprintf("File not readable: '%s'", $schemaFile));
     }
     try {
         $soapMessage = $response->getSoapMessage();
     } catch (\Exception $e) {
         $this->addMessage(sprintf("Error loading SOAP message: [%s] %s", get_class($e), $e->getMessage()));
         return false;
     }
     $dom = $soapMessage->getDom();
     try {
         ErrorHandler::start();
         if ($dom->schemaValidate($schemaFile)) {
             $valid = true;
         }
         ErrorHandler::stop(true);
     } catch (\Exception $e) {
         $this->addMessage(sprintf("Failed schema validate (schema:%s): [%s] %s", $schemaFile, get_class($e), $e->getMessage()));
     }
     if (ErrorHandler::started()) {
         ErrorHandler::stop();
     }
     return $valid;
 }
 /**
  * {@inheritdoc}
  * @see \Saml\Ecp\Response\Validator\ValidatorInterface::isValid()
  */
 public function isValid(ResponseInterface $response)
 {
     $soapMessage = $response->getSoapMessage();
     $bodyElements = $soapMessage->getBodyElements();
     if (!$bodyElements->length) {
         $this->addMessage('No body elements');
         return false;
     }
     $element = $bodyElements->item(0);
     $elementPrefix = $element->prefix;
     $elementName = $element->localName;
     $expectedElementName = $this->getOption(self::OPT_ELEMENT_NAME, $this->_defElementName);
     if ($elementName != $expectedElementName) {
         $this->addMessage(sprintf("The element name '%s' does not correspond to the expected '%s'", $elementName, $expectedElementName));
         return false;
     }
     $expectedElementNs = $this->getOption(self::OPT_ELEMENT_NS, $this->_defElementNs);
     $elementNs = $element->getAttribute('xmlns:' . $elementPrefix);
     if ($elementNs != $expectedElementNs) {
         $this->addMessage(sprintf("The element namespace '%s' does not correspond to the expected '%s'", $elementNs, $expectedElementNs));
         return false;
     }
     return true;
 }
 /**
  * {@inheritdoc}
  * @see \Saml\Ecp\Response\Validator\ValidatorInterface::isValid()
  */
 public function isValid(ResponseInterface $response)
 {
     return $this->_isValidSoapMessage($response->getSoapMessage());
 }