jweLoader->loadAndDecryptWithKeySet($token, $encryptionKeySet, $recipient); $this->checkContentTypeHeader($jwe, $recipient); if ($jwe->getPayload() === null) { throw new InvalidArgumentException('The token has no payload.'); } return $this->jwsLoader->loadAndVerifyWithKeySet($jwe->getPayload(), $signatureKeySet, $signature); } private function checkContentTypeHeader(JWE $jwe, int $recipient): void { $cty = match (true) { $jwe->hasSharedProtectedHeaderParameter('cty') => $jwe->getSharedProtectedHeaderParameter('cty'), $jwe->hasSharedHeaderParameter('cty') => $jwe->getSharedHeaderParameter('cty'), $jwe->getRecipient($recipient) ->hasHeaderParameter('cty') => $jwe->getRecipient($recipient) ->getHeaderParameter('cty'), default => throw new InvalidArgumentException('The token is not a nested token.'), }; if (! is_string($cty)) { throw new InvalidArgumentException('Invalid "cty" header parameter.'); } if (strcasecmp($cty, 'jwt') !== 0) { throw new InvalidArgumentException('The token is not a nested token.'); } } }