Beispiel #1
0
 /**
  * Returns the signature from given data
  *
  * @param array $header
  * @param string $data
  *
  * @return Signature
  */
 protected function parseSignature(array $header, $data)
 {
     if ($data == '' || !isset($header['alg']) || $header['alg'] == 'none') {
         return null;
     }
     $hash = $this->deserializer->fromBase64URL($data);
     return new Signature($hash);
 }
 /**
  * {@inheritdoc}
  */
 public function decode($token)
 {
     $parser = new Parser();
     $token = $parser->parse($token);
     try {
         if (true === $token->verify(new Sha512(), $this->secret)) {
             $serializer = new Serializer();
             $deserializer = new Deserializer();
             $claims = $token->getClaims();
             return (array) $deserializer->fromJSON($serializer->toJSON($claims));
         } else {
             return false;
         }
     } catch (\BadMethodCallException $e) {
         return false;
     }
 }