부터: 3.0.4
저자: Luís Otávio Cobucci Oblonczyk (lcobucci@gmail.com)
예제 #1
0
 /**
  * @test
  *
  * @uses Lcobucci\JWT\Signer\Ecdsa::__construct
  * @uses Lcobucci\JWT\Signer\Key
  *
  * @covers Lcobucci\JWT\Signer\Ecdsa::doVerify
  * @covers Lcobucci\JWT\Signer\Ecdsa::createSigningHash
  * @covers Lcobucci\JWT\Signer\Ecdsa::extractSignature
  */
 public function doVerifyShouldDelegateToEcdsaSignerUsingPublicKey()
 {
     $signer = $this->getSigner();
     $key = new Key('testing');
     $publicKey = $this->getMock(PublicKeyInterface::class);
     $this->parser->expects($this->once())->method('getPublicKey')->with($key)->willReturn($publicKey);
     $this->adapter->expects($this->exactly(3))->method('hexDec')->willReturn('123');
     $this->signer->expects($this->once())->method('verify')->with($publicKey, $this->isInstanceOf(Signature::class), $this->isType('string'))->willReturn(true);
     $this->assertTrue($signer->doVerify('testing', 'testing2', $key));
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function doVerify(string $expected, string $payload, Key $key) : bool
 {
     return $this->signer->verify($this->parser->getPublicKey($key), $this->extractSignature($expected), $this->createSigningHash($payload));
 }
예제 #3
0
 /**
  * @test
  *
  * @expectedException \InvalidArgumentException
  *
  * @uses \Lcobucci\JWT\Signer\Ecdsa\KeyParser::__construct
  * @uses \Lcobucci\JWT\Signer\Key
  *
  * @covers \Lcobucci\JWT\Signer\Ecdsa\KeyParser::getPublicKey
  * @covers \Lcobucci\JWT\Signer\Ecdsa\KeyParser::getKeyContent
  */
 public function getPublicKeyShouldRaiseExceptionWhenAWrongKeyWasGiven()
 {
     $this->publicKeySerializer->expects($this->never())->method('parse');
     $parser = new KeyParser($this->privateKeySerializer, $this->publicKeySerializer);
     $parser->getPublicKey($this->getPrivateKey());
 }
예제 #4
0
파일: Ecdsa.php 프로젝트: lcobucci/jwt
 /**
  * {@inheritdoc}
  */
 public function doVerify(string $expected, string $payload, Key $key) : bool
 {
     return $this->adapter->verifyHash($expected, $this->keyParser->getPublicKey($key), $this->adapter->createSigningHash($payload, $this->getAlgorithm()), $this->getAlgorithm());
 }