getKeys() public method

Returns all keys in the key set.
public getKeys ( ) : Jose\Object\JWKInterface[]
return Jose\Object\JWKInterface[] An array of keys stored in the key set
Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function getKeys()
 {
     $keys = [];
     foreach ($this->jwkset->getKeys() as $key) {
         if (in_array($key->get('kty'), ['none', 'oct'])) {
             continue;
         }
         $keys[] = $key->toPublic();
     }
     return $keys;
 }
Beispiel #2
0
 /**
  * @param \Jose\Object\JWSInterface       $jws
  * @param \Jose\Object\JWKSetInterface    $jwk_set
  * @param \Jose\Object\SignatureInterface $signature
  * @param string|null                     $detached_payload
  *
  * @return bool
  */
 private function verifySignature(Object\JWSInterface $jws, Object\JWKSetInterface $jwk_set, Object\SignatureInterface $signature, $detached_payload = null)
 {
     $input = $this->getInputToVerify($jws, $signature, $detached_payload);
     foreach ($jwk_set->getKeys() as $jwk) {
         $algorithm = $this->getAlgorithm($signature);
         try {
             $this->checkKeyUsage($jwk, 'verification');
             $this->checkKeyAlgorithm($jwk, $algorithm->getAlgorithmName());
             if (true === $algorithm->verify($jwk, $input, $signature->getSignature())) {
                 return true;
             }
         } catch (\Exception $e) {
             //We do nothing, we continue with other keys
             continue;
         }
     }
     return false;
 }