getAlgorithmName() public method

public getAlgorithmName ( ) : string
return string
示例#1
0
文件: Jws.php 项目: 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);
 }
示例#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();
     }
 }