Esempio n. 1
0
 public function tearDown()
 {
     // be sure the error handler has been stopped
     if (ErrorHandler::started()) {
         ErrorHandler::stop();
         $this->fail('ErrorHandler not stopped');
     }
 }
Esempio n. 2
0
 public function testStarted()
 {
     $this->assertFalse(ErrorHandler::started());
     ErrorHandler::start();
     $this->assertTrue(ErrorHandler::started());
     ErrorHandler::stop();
     $this->assertFalse(ErrorHandler::started());
 }
 /**
  * Loads the SOAP message from a string.
  * 
  * @param string $soapData
  * @throws SoapException\LoadSoapDataException
  */
 public function fromString($soapData)
 {
     $dom = $this->getDom();
     try {
         ErrorHandler::start();
         $dom->loadXML($soapData);
         ErrorHandler::stop(true);
     } catch (\Exception $e) {
         if (ErrorHandler::started()) {
             ErrorHandler::stop();
         }
         throw new SoapException\LoadSoapDataException($e->getMessage());
     }
     $rootElement = $dom->documentElement;
     if ('envelope' != strtolower($rootElement->localName)) {
         throw new SoapException\LoadSoapDataException(sprintf("Invalid root element '%s'", $rootElement->localName));
     }
 }
 /**
  * {@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;
 }
Esempio n. 5
0
 /**
  * Log a message to this writer.
  *
  * @param array $event log data event
  * @return void
  */
 public function write(array $event)
 {
     foreach ($this->filters as $filter) {
         if (!$filter->filter($event)) {
             return;
         }
     }
     $errorHandlerStarted = false;
     if ($this->convertWriteErrorsToExceptions && !ErrorHandler::started()) {
         ErrorHandler::start($this->errorsToExceptionsConversionLevel);
         $errorHandlerStarted = true;
     }
     try {
         $this->doWrite($event);
     } catch (\Exception $e) {
         if ($errorHandlerStarted) {
             ErrorHandler::stop();
             $errorHandlerStarted = false;
         }
         throw $e;
     }
     if ($errorHandlerStarted) {
         $error = ErrorHandler::stop();
         $errorHandlerStarted = false;
         if ($error) {
             throw new Exception\RuntimeException("Unable to write", 0, $error);
         }
     }
 }