OneLogin_Saml2_Response::checkOneAuthnStatement PHP Method

checkOneAuthnStatement() public method

Checks that the samlp:Response/saml:Assertion/saml:AuthnStatement element exists and is unique.
public checkOneAuthnStatement ( ) : boolean
return boolean true if the AuthnStatement element exists and is unique
    public function checkOneAuthnStatement()
    {
        $entries = $this->_queryAssertion("/saml:AuthnStatement");
        if ($entries->length == 1) {
            return true;
        } else {
            return false;
        }
    }

Usage Example

示例#1
0
 /**
  * Tests the checkOneAuthnStatement method of SamlResponse
  *
  * @covers OneLogin_Saml2_Response::checkOneAuthnStatement
  */
 public function testCheckOneAuthNStatement()
 {
     $xml = file_get_contents(TEST_ROOT . '/data/responses/invalids/no_authnstatement.xml.base64');
     $response = new OneLogin_Saml2_Response($this->_settings, $xml);
     $this->assertFalse($response->checkOneAuthnStatement());
     $xml2 = file_get_contents(TEST_ROOT . '/data/responses/valid_response.xml.base64');
     $response2 = new OneLogin_Saml2_Response($this->_settings, $xml2);
     $this->assertTrue($response2->checkOneAuthnStatement());
 }