/** * @return \Jose\Object\JWKInterface[] */ public function getKeys() { $content = json_decode($this->getContent(), true); Assertion::isArray($content, 'Invalid content.'); $jwkset = new JWKSet(); foreach ($content as $kid => $cert) { $jwk = KeyConverter::loadKeyFromCertificate($cert); Assertion::notEmpty($jwk, 'Invalid content.'); if (is_string($kid)) { $jwk['kid'] = $kid; } $jwkset->addKey(new JWK($jwk)); } return $jwkset->getKeys(); }
/** * {@inheritdoc} */ public function loadAndVerifySignatureUsingKeyAndDetachedPayload($input, Object\JWKInterface $jwk, array $allowed_algorithms, $detached_payload, &$signature_index = null) { $jwk_set = new Object\JWKSet(); $jwk_set->addKey($jwk); return $this->loadAndVerifySignature($input, $jwk_set, $allowed_algorithms, $detached_payload, $signature_index); }
/** * This method creates the JWKSet and populate it with keys. */ protected function createNewObject() { $jwkset = new JWKSet(); for ($i = 0; $i < $this->nb_keys; $i++) { $key = $this->createJWK(); $jwkset->addKey($key); } return $jwkset; }
/** * {@inheritdoc} * * @throws \InvalidArgumentException */ public function verifyWithKey(Object\JWSInterface $jws, Object\JWKInterface $jwk, $detached_payload = null, &$recipient_index = null) { $jwk_set = new Object\JWKSet(); $jwk_set->addKey($jwk); $this->verifySignatures($jws, $jwk_set, $detached_payload, $recipient_index); }
/** * {@inheritdoc} */ public function decryptUsingKey(Object\JWEInterface &$jwe, Object\JWKInterface $jwk, &$recipient_index = null) { $jwk_set = new Object\JWKSet(); $jwk_set->addKey($jwk); $this->decryptUsingKeySet($jwe, $jwk_set, $recipient_index); }
/** * @param string $x5u * @param bool $allow_unsecured_connection * * @return \Jose\Object\JWKSetInterface */ public static function createFromX5U($x5u, $allow_unsecured_connection = false) { $content = self::downloadContent($x5u, $allow_unsecured_connection); $content = json_decode($content, true); if (!is_array($content)) { throw new \InvalidArgumentException('Invalid content.'); } $jwkset = new JWKSet(); foreach ($content as $kid => $cert) { $jwk = KeyConverter::loadKeyFromCertificate($cert); if (empty($jwk)) { throw new \InvalidArgumentException('Invalid content.'); } if (is_string($kid)) { $jwk['kid'] = $kid; } $jwkset->addKey(new JWK($jwk)); } return $jwkset; }
/** * @return null|\Jose\Object\JWKSetInterface */ public function getPublicKeySet() { Assertion::true($this->hasPublicKeySet(), 'The client has no public key set'); if ($this->hasJwks()) { return new JWKSet($this->getJwks()); } if ($this->hasJwksUri()) { return JWKFactory::createFromJKU($this->getJwksUri()); } if ($this->hasClientSecret()) { $jwk_set = new JWKSet(); $jwk_set->addKey(new JWK(['kty' => 'oct', 'use' => 'sig', 'k' => $this->getClientSecret()])); return $jwk_set; } }