getAlgorithmName() public method

public getAlgorithmName ( ) : string
return string
Esempio n. 1
0
File: Jws.php Progetto: emarref/jwt
 public function sign(Token $token)
 {
     $token->addHeader(new Algorithm($this->encryption->getAlgorithmName()));
     $rawSignature = $this->getUnsignedValue($token);
     $signature = $this->encryption->encrypt($rawSignature);
     $token->setSignature($signature);
 }
Esempio n. 2
0
 /**
  * @param Token $token
  * @throws InvalidSignatureException
  */
 public function verify(Token $token)
 {
     /** @var HeaderParameter\Algorithm $algorithmParameter */
     $algorithmParameter = $token->getHeader()->findParameterByName(HeaderParameter\Algorithm::NAME);
     if (null === $algorithmParameter) {
         throw new \RuntimeException('Algorithm parameter not found in token header.');
     }
     if ($algorithmParameter->getValue() !== $this->encryption->getAlgorithmName()) {
         throw new \RuntimeException(sprintf('Cannot use "%s" algorithm to decrypt token encrypted with algorithm "%s".', $this->encryption->getAlgorithmName(), $algorithmParameter->getValue()));
     }
     if (!$this->encryption->verify($this->signer->getUnsignedValue($token), $token->getSignature())) {
         throw new InvalidSignatureException();
     }
 }