Jose\JWTLoader::verify PHP Method

verify() public method

public verify ( Jose\Object\JWSInterface $jws, Jose\Object\JWKSetInterface $signature_key_set, $detached_payload = null )
$jws Jose\Object\JWSInterface
$signature_key_set Jose\Object\JWKSetInterface
    public function verify(Object\JWSInterface $jws, Object\JWKSetInterface $signature_key_set, $detached_payload = null)
    {
        Assertion::inArray($jws->getSignature(0)->getProtectedHeader('alg'), $this->getSupportedSignatureAlgorithms(), sprintf('The signature algorithm "%s" is not supported or not allowed.', $jws->getSignature(0)->getProtectedHeader('alg')));
        $index = null;
        $this->verifier->verifyWithKeySet($jws, $signature_key_set, $detached_payload, $index);
        Assertion::notNull($index, 'JWS signature(s) verification failed.');
        $this->checker_manager->checkJWS($jws, $index);
        return $index;
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function decode($token)
 {
     try {
         $jws = $this->jwt_loader->load($token, $this->encryption_jwkset, null !== $this->encryption_jwkset);
         $this->jwt_loader->verify($jws, $this->signature_jwkset);
         return $jws->getClaims();
     } catch (\Exception $e) {
         $reason = $this->getDecodeErrorReason($e->getMessage());
         throw new JWTDecodeFailureException($reason, sprintf('Invalid JWT Token: %s', $e->getMessage()), $e);
     }
 }