Exemplo n.º 1
0
 public function testEncode()
 {
     $data = array('url' => 'https://openidconnect.info');
     $exepted_enc = '{"url":"https://openidconnect.info"}';
     $enc = Akita_OpenIDConnect_Util_Json::encode($data);
     $this->assertEquals($exepted_enc, $enc);
 }
Exemplo n.º 2
0
 /**
  * return JWT Signature Base String
  *
  * @return string Signature Base String
  */
 public function getSignatureBaseString($payload_is_array = false)
 {
     $token = Akita_OpenIDConnect_Util_Base64::urlEncode(Akita_OpenIDConnect_Util_Json::encode($this->_header)) . ".";
     if ($payload_is_array) {
         $token .= Akita_OpenIDConnect_Util_Base64::urlEncode(Akita_OpenIDConnect_Util_Json::encode($this->_payload));
     } else {
         $token .= Akita_OpenIDConnect_Util_Base64::urlEncode($this->_payload);
     }
     return $token;
 }
Exemplo n.º 3
0
$request = new Akita_OpenIDConnect_Server_Request('resource', $_SERVER, $_GET, $headers);
$dataHandler = new Akita_OpenIDConnect_Server_Sample_DataHandler($request);
$resource = new Akita_OpenIDConnect_Server_UserInfo();
try {
    $authInfo = $resource->processRequest($dataHandler);
} catch (Akita_OAuth2_Server_Error $error) {
    // error handling
    header('HTTP/1.1 ' . $error->getOAuth2Code());
    header('Content-Type: application/json;charset=UTF-8');
    header('Cache-Control: no-store');
    header('Pragma: no-cache');
    $res = array();
    $res['error'] = $error->getOAuth2Error();
    $desc = $error->getOAuth2ErrorDescription();
    if (!empty($desc)) {
        $res['error_description'] = $desc;
    }
    echo Akita_OpenIDConnect_Util_Json::encode($res);
    exit;
}
// build response
$res = array();
foreach ($authInfo->userInfoClaims as $claim_name) {
    $res[$claim_name] = $claim_name . "_value";
}
header('HTTP/1.1 200 OK');
header('Content-Type: application/json;charset=UTF-8');
header('Cache-Control: no-store');
header('Pragma: no-cache');
echo Akita_OpenIDConnect_Util_Json::encode($res);