Example #1
0
 /**
  * @param string $jsonWebToken
  *
  * @return JWT $this
  */
 public function load($jsonWebToken)
 {
     $this->jsonWebToken = $jsonWebToken;
     $jwtSegment = explode('.', $this->jsonWebToken);
     if (count($jwtSegment) != 3) {
         $this->payloadData = array();
         $this->tokenValidated = false;
         return $this;
     }
     $createdSignature = $this->secureHash($jwtSegment[0] . '.' . $jwtSegment[1]);
     $providedSignature = $this->encoder->decode($jwtSegment[2]);
     if ($this->verifyHash($createdSignature, $providedSignature)) {
         $this->payloadData = $this->encoder->decodeData($jwtSegment[1]);
         $this->tokenValidated = true;
     } else {
         $this->payloadData = array();
         $this->tokenValidated = false;
     }
     return $this;
 }
Example #2
0
 /**
  * Returns value of a cached key.
  *
  * This method does not check if there is a value available for the given key, may return unexpected values if not.
  * Use has() to prevent this issue.
  *
  * @param string $key
  *
  * @return mixed
  */
 public function get($key)
 {
     $encoded = $this->redis->get($this->redis->prefix($key));
     return $this->encoder->decode($encoded);
 }