예제 #1
0
 /**
  * @test
  *
  * @expectedException \InvalidArgumentException
  *
  * @uses \Lcobucci\JWT\Signer\Ecdsa\KeyParser::__construct
  * @uses \Lcobucci\JWT\Signer\Key
  *
  * @covers \Lcobucci\JWT\Signer\Ecdsa\KeyParser::getPrivateKey
  * @covers \Lcobucci\JWT\Signer\Ecdsa\KeyParser::getKeyContent
  */
 public function getPrivateKeyShouldRaiseExceptionWhenAWrongKeyWasGiven()
 {
     $this->privateKeySerializer->expects($this->never())->method('parse');
     $parser = new KeyParser($this->privateKeySerializer, $this->publicKeySerializer);
     $parser->getPrivateKey($this->getPublicKey());
 }
예제 #2
0
 /**
  * Parses a private key from the given PEM content
  *
  * @param Key $key
  *
  * @return \Mdanter\Ecc\Crypto\Key\PrivateKeyInterface
  */
 public function getPrivateKey(Key $key)
 {
     return $this->privateKeySerializer->parse($this->getKeyContent($key, 'EC PRIVATE KEY'));
 }
예제 #3
0
 /**
  * @param string $key
  * @param PrivateKeySerializerInterface|PublicKeySerializerInterface $serializer
  * @return PrivateKeyInterface|PublicKeyInterface
  * @throws \Exception
  */
 private function deserialize($key, $serializer)
 {
     try {
         return $serializer->parse($key);
     } catch (\Exception $e) {
         throw new \Exception('Invalid key.');
     }
 }