private function getContentEncryptionAlgorithm(Object\JWEInterface $jwe) { $algorithm = null; foreach ($jwe->getRecipients() as $recipient) { $complete_headers = array_merge($jwe->getSharedProtectedHeaders(), $jwe->getSharedHeaders(), $recipient->getHeaders()); Assertion::keyExists($complete_headers, 'enc', 'Parameter "enc" is missing.'); if (null === $algorithm) { $algorithm = $complete_headers['enc']; } else { Assertion::eq($algorithm, $complete_headers['enc'], 'Foreign content encryption algorithms are not allowed.'); } } $content_encryption_algorithm = $this->getJWAManager()->getAlgorithm($algorithm); Assertion::isInstanceOf($content_encryption_algorithm, Algorithm\ContentEncryptionAlgorithmInterface::class, sprintf('The content encryption algorithm "%s" is not supported or not a content encryption algorithm instance.', $algorithm)); return $content_encryption_algorithm; }