getNameIdFormat() 공개 메소드

Gets the NameID Format provided by the SAML response from the IdP.
public getNameIdFormat ( ) : string
리턴 string Name ID Format
예제 #1
0
 /**
  * Tests the getNameIdFormat method of the OneLogin_Saml2_Response
  *
  * @covers OneLogin_Saml2_Response::getNameIdFormat
  */
 public function testGetNameIdFormat()
 {
     $xml = file_get_contents(TEST_ROOT . '/data/responses/response1.xml.base64');
     $response = new OneLogin_Saml2_Response($this->_settings, $xml);
     $this->assertEquals('urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress', $response->getNameIdFormat());
     $xml2 = file_get_contents(TEST_ROOT . '/data/responses/response_encrypted_nameid.xml.base64');
     $response2 = new OneLogin_Saml2_Response($this->_settings, $xml2);
     $this->assertEquals('urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified', $response2->getNameIdFormat());
     $xml3 = file_get_contents(TEST_ROOT . '/data/responses/valid_encrypted_assertion.xml.base64');
     $response3 = new OneLogin_Saml2_Response($this->_settings, $xml3);
     $this->assertEquals('urn:oasis:names:tc:SAML:2.0:nameid-format:transient', $response3->getNameIdFormat());
     $xml4 = file_get_contents(TEST_ROOT . '/data/responses/invalids/no_nameid.xml.base64');
     $response4 = new OneLogin_Saml2_Response($this->_settings, $xml4);
     try {
         $nameId4 = $response4->getNameIdFormat();
     } catch (Exception $e) {
         $this->assertContains('Not NameID found in the assertion of the Response', $e->getMessage());
     }
 }
예제 #2
0
파일: Auth.php 프로젝트: onelogin/php-saml
 /**
  * Process the SAML Response sent by the IdP.
  *
  * @param string|null $requestId The ID of the AuthNRequest sent by this SP to the IdP
  *
  * @throws OneLogin_Saml2_Error
  */
 public function processResponse($requestId = null)
 {
     $this->_errors = array();
     if (isset($_POST) && isset($_POST['SAMLResponse'])) {
         // AuthnResponse -- HTTP_POST Binding
         $response = new OneLogin_Saml2_Response($this->_settings, $_POST['SAMLResponse']);
         if ($response->isValid($requestId)) {
             $this->_attributes = $response->getAttributes();
             $this->_nameid = $response->getNameId();
             $this->_nameidFormat = $response->getNameIdFormat();
             $this->_authenticated = true;
             $this->_sessionIndex = $response->getSessionIndex();
             $this->_sessionExpiration = $response->getSessionNotOnOrAfter();
         } else {
             $this->_errors[] = 'invalid_response';
             $this->_errorReason = $response->getError();
         }
     } else {
         $this->_errors[] = 'invalid_binding';
         throw new OneLogin_Saml2_Error('SAML Response not found, Only supported HTTP_POST Binding', OneLogin_Saml2_Error::SAML_RESPONSE_NOT_FOUND);
     }
 }