예제 #1
0
 /**
  * @param string $token
  */
 public function __construct(JsonWebToken $token)
 {
     /**
      * Init JWE following rfc steps
      * @see https://tools.ietf.org/html/rfc7516#section-3.3 Example JWE
      */
     $this->header = json_encode($token->getHeaders());
     $this->ciphertext = $this->encrypt(json_encode($token->getClaims()));
 }
예제 #2
0
 /**
  * Check if valid access token is set and get one if not.
  *
  * @return $this
  */
 protected function validateAccessToken()
 {
     if (empty($this->accessToken)) {
         $this->accessToken = $this->getAccessToken();
     } else {
         $JWT = new Token\JsonWebToken($this->accessToken);
         if ($JWT->getExpireDateInSeconds(false) < 0) {
             $this->accessToken = $this->getAccessToken();
         }
     }
     return $this;
 }