@param array                     $complete_header The complete header
@param \Jose\Object\JWKInterface $key

@return \Jose\Algorithm\SignatureAlgorithmInterface
547033
private function getSignatureAlgorithm(array $complete_header, Object\JWKInterface $key)
    {
        Assertion::keyExists($complete_header, 'alg', 'No "alg" parameter set in the header.');

        Assertion::false(
            $key->has('alg') && $key->get('alg') !== $complete_header['alg'],
            sprintf('The algorithm "%s" is not allowed with this key.', $complete_header['alg'])
        );

        $signature_algorithm = $this->getJWAManager()->getAlgorithm($complete_header['alg']);
        Assertion::isInstanceOf($signature_algorithm, Algorithm\SignatureAlgorithmInterface::class, sprintf('The algorithm "%s" is not supported.', $complete_header['alg']));

        return $signature_algorithm;
    }
1246126
private function getContentEncryptionAlgorithm(array $complete_headers)
    {
        $content_encryption_algorithm = $this->getJWAManager()->getAlgorithm($complete_headers['enc']);
        Assertion::isInstanceOf($content_encryption_algorithm, Algorithm\ContentEncryptionAlgorithmInterface::class, sprintf('The key encryption algorithm "%s" is not supported or does not implement ContentEncryptionInterface.', $complete_headers['enc']));

        return $content_encryption_algorithm;
    }
1104500
public function addResponseHeader(ResponseHeader $header, $key = '')
    {
        if (empty($key)) {
            $this->responseHeaders[] = $header->toArray();
        } else {
            $this->responseHeaders[$key] = $header->toArray();
        }

        return $this;
    }
534405
public function header( string$key=null )
	{
		return ( isset($key) ?
			$this->headers[ucwords( strtolower($key), '-' )]
			:
			$this->getHeaders()
		);
	}
711202
public function getHeader($key)
    {
        if (!isset($this->headers[$key])) {
            return false;
        }
        
        return $this->headers[$key];
    }
974194
private function getHeader($key)
    {
        if (! $this->headers) {
            $this->headers = $this->getHeaders();
        }
        if (array_key_exists($key, $this->headers)) {
            //if redirects encountered, return the final values
            if (is_array($this->headers[$key])) {
                return end($this->headers[$key]);
            } else {
                return $this->headers[$key];
            }
        }
    }
748056
public function getHeader($key)
	{
		$key = strtolower($key);

		return isset($this->headers[$key]) ? $this->headers[$key] : null;
	}
1328204
public function header($key, $default = null)
    {
        if (array_key_exists($key, $this->headers)) {
            return $this->headers[$key];
        }

        return $default;
    }
1341588
public function getResponseHeader($key, $first = true): string
    {
        $header = $this->response->getHeader($key);
        $headerFirst = $header[0] ?? '';
        return $first ? $headerFirst : $header;
    }
1261198
public function getCompact($key)
    {
        $headers   = self::base64Encode(Parser::encode($this->headers));
        $claim     = self::base64Encode($this->claim);
        $signature = $this->getEncodedSignature($key);

        return $headers . '.' . $claim . '.' . $signature;
    }
14040
public function getAdditionalHeader(string $key)
    {
        if (! $this->hasAdditionalHeader($key)) {
            return null;
        }

        return $this->additionalHeaders[$key];
    }
1239771
public static function getTrustedHeaderName($key)
    {
        if (!array_key_exists($key, self::$trustedHeaders)) {
            throw new \InvalidArgumentException(
                sprintf('Unable to get the trusted header name for key "%s".', $key)
            );
        }

        return self::$trustedHeaders[$key];
    }
1229079
public function removeHeader($key)
    {
        if (isset($this->headers[$key])) {
            unset($this->headers[$key]);
        }
        return $this;
    }
62924
private function checkUsage(JWKInterface $key, $usage)
    {
        $use = $key->get('use');
        switch ($usage) {
            case 'verification':
            case 'signature':
                Assertion::eq('sig', $use, 'Key cannot be used to sign or verify a signature');

                return true;
            case 'encryption':
            case 'decryption':
                Assertion::eq('enc', $use, 'Key cannot be used to encrypt or decrypt');

                return true;
            default:
                throw new \InvalidArgumentException('Unsupported key usage.');
        }
    }
610390
public function authenticateRequestWithSharedKey(
        RequestInterface $request,
        SharedAuthenticationKey $key
    ): RequestInterface {
        $mac = \ParagonIE_Sodium_Compat::crypto_auth(
            (string) $request->getBody(),
            $key->getString(true)
        );
        return $request->withAddedHeader(
            self::HEADER_AUTH_NAME,
            Base64UrlSafe::encode($mac)
        );
    }
308065
public function getResponseHeader($key = null) {
        if (null != $key) {
            if (array_key_exists($key, $this->response_headers)) {
                return $this->response_headers[$key];
            }
        } else {
            return $this->response_headers;
        }
    }
840035
public static function createJWSWithDetachedPayloadToCompactJSON($payload, JWKInterface $signature_key, array $protected_headers, LoggerInterface $logger = null)
    {
        $jws = self::createJWSWithDetachedPayloadAndSign($payload, $signature_key, $protected_headers, [], $logger);

        return $jws->toCompactJSON(0);
    }