public boolean isChallenged(
            final HttpHost host,
            final ChallengeType challengeType,
            final HttpResponse response,
            final AuthExchange authExchange,
            final HttpContext context) {
        final HttpClientContext clientContext = HttpClientContext.cast(context);
        if (checkChallenged(challengeType, response, clientContext)) {
            return true;
        }
        switch (authExchange.getState()) {
        case CHALLENGED:
        case HANDSHAKE:
            if (LOG.isDebugEnabled()) {
                // The mutual auth may still fail
                LOG.debug("{} Server has accepted authentication", clientContext.getExchangeId());
            }
            authExchange.setState(AuthExchange.State.SUCCESS);
            break;
        case SUCCESS:
            break;
        default:
            authExchange.setState(AuthExchange.State.UNCHALLENGED);
        }
        return false;
    }
Determines whether the given response represents an authentication challenge, and updates
the {@link AuthExchange} state.

@param host the hostname of the opposite endpoint.
@param challengeType the challenge type (target or proxy).
@param response the response message head.
@param authExchange the current authentication exchange state. Gets updated.
@param context 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