Ejemplo n.º 1
0
 public function setCodeHash($authorizationCodeString)
 {
     // bit : 256/384/512
     if (isset($this->_header['alg']) && $this->_header['alg'] != 'none') {
         $bit = substr($this->_header['alg'], 2, 3);
     } else {
         // TODO: Error case. throw exception???
         $bit = '256';
     }
     $len = (int) $bit / 16;
     $this->_payload['c_hash'] = Akita_OpenIDConnect_Util_Base64::urlEncode(substr(hash('sha' . $bit, $authorizationCodeString, true), 0, $len));
 }
Ejemplo n.º 2
0
 public function testUrlDecode()
 {
     $dec_str = "1";
     $str = "MQ";
     $dec = Akita_OpenIDConnect_Util_Base64::urlDecode($str);
     $this->assertEquals($dec_str, $dec);
     $dec_str = "1234";
     $str = "MTIzNA";
     $dec = akita_openidconnect_util_base64::urlDecode($str);
     $this->assertequals($dec_str, $dec);
     $dec_str = "ABCDEFG";
     $str = "QUJDREVGRw";
     $dec = akita_openidconnect_util_base64::urlDecode($str);
     $this->assertequals($dec_str, $dec);
 }
Ejemplo n.º 3
0
 /**
  * return JWT Header array
  *
  * @param string $jwt JWT string
  * @return array JWT Header
  */
 public static function getHeader($jwt)
 {
     // split 3 parts
     $part = explode('.', $jwt);
     if (!is_array($part) || empty($part) || count($part) !== 3) {
         return false;
     }
     $header = json_decode(Akita_OpenIDConnect_Util_Base64::urlDecode($part[0]), true);
     return $header;
 }