Esempio n. 1
0
 public function testGetHeader()
 {
     $jwt = "";
     $header = Akita_OpenIDConnect_Util_JOSE_JWT::getHeader($jwt);
     $this->assertEquals(false, $header);
     $jwt = "..";
     $header = Akita_OpenIDConnect_Util_JOSE_JWT::getHeader($jwt);
     $this->assertEquals(false, $header);
     $jwt = "eyJhbGciOiJub25lIn0.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.";
     $header = Akita_OpenIDConnect_Util_JOSE_JWT::getHeader($jwt);
     $expect_header = array('alg' => 'none');
     $this->assertEquals($expect_header, $header);
 }
Esempio n. 2
0
 /**
  * load ID Token String and return object
  *
  * @param string $idTokenString ID Token String
  * @return Akita_OpenIDConnect_Model_IDToken 
  */
 public static function loadTokenString($idTokenString)
 {
     $header = Akita_OpenIDConnect_Util_JOSE_JWT::getHeader($idTokenString);
     $payload = Akita_OpenIDConnect_Util_JOSE_JWT::getPayload($idTokenString, true);
     // validation
     if (is_array($header) && is_array($payload)) {
         $idTokenObj = new Akita_OpenIDConnect_Model_IDToken($header, $payload);
         $idTokenObj->setTokenString($idTokenString);
         return $idTokenObj;
     } else {
         throw new Exception('InvalidTokenFormat');
     }
 }