OneLogin_Saml2_Response::checkStatus PHP Метод

checkStatus() публичный Метод

Checks if the Status is success
public checkStatus ( )
    public function checkStatus()
    {
        $status = OneLogin_Saml2_Utils::getStatus($this->document);
        if (isset($status['code']) && $status['code'] !== OneLogin_Saml2_Constants::STATUS_SUCCESS) {
            $explodedCode = explode(':', $status['code']);
            $printableCode = array_pop($explodedCode);
            $statusExceptionMsg = 'The status code of the Response was not Success, was ' . $printableCode;
            if (!empty($status['msg'])) {
                $statusExceptionMsg .= ' -> ' . $status['msg'];
            }
            throw new Exception($statusExceptionMsg);
        }
    }

Usage Example

Пример #1
0
 /**
  * Tests the checkStatus method of the OneLogin_Saml2_Response
  *
  * @covers OneLogin_Saml2_Response::checkStatus
  */
 public function testCheckStatus()
 {
     $xml = file_get_contents(TEST_ROOT . '/data/responses/response1.xml.base64');
     $response = new OneLogin_Saml2_Response($this->_settings, $xml);
     $response->checkStatus();
     $xmlEnc = file_get_contents(TEST_ROOT . '/data/responses/valid_encrypted_assertion.xml.base64');
     $responseEnc = new OneLogin_Saml2_Response($this->_settings, $xmlEnc);
     $response->checkStatus();
     $xml2 = file_get_contents(TEST_ROOT . '/data/responses/invalids/status_code_responder.xml.base64');
     $response2 = new OneLogin_Saml2_Response($this->_settings, $xml2);
     try {
         $response2->checkStatus();
         $this->assertTrue(false);
     } catch (Exception $e) {
         $this->assertContains('The status code of the Response was not Success, was Responder', $e->getMessage());
     }
     $xml3 = file_get_contents(TEST_ROOT . '/data/responses/invalids/status_code_responer_and_msg.xml.base64');
     $response3 = new OneLogin_Saml2_Response($this->_settings, $xml3);
     try {
         $response3->checkStatus();
         $this->assertTrue(false);
     } catch (Exception $e) {
         $this->assertContains('The status code of the Response was not Success, was Responder -> something_is_wrong', $e->getMessage());
     }
 }