/** * {@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; }