private boolean checkChallenged(
            final ChallengeType challengeType,
            final HttpResponse response,
            final HttpClientContext clientContext) {
        final int challengeCode;
        switch (challengeType) {
            case TARGET:
                challengeCode = HttpStatus.SC_UNAUTHORIZED;
                break;
            case PROXY:
                challengeCode = HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED;
                break;
            default:
                throw new IllegalStateException("Unexpected challenge type: " + challengeType);
        }

        if (response.getCode() == challengeCode) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("{} Authentication required", clientContext.getExchangeId());
            }
            return true;
        }
        return false;
    }
Determines whether the given response represents an authentication challenge, without
changing the {@link AuthExchange} state.

@param challengeType the challenge type (target or proxy).
@param response the response message head.
@param clientContext the current execution context.
@return {@code true} if the response message represents an authentication challenge,
  {@code false} otherwise.
httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/AuthenticationHandler.java