class ResourceContext {

    public void sendAuthenticateChallenges(ResourceException exc) {

        // first check to see if this is an auth failure and if
        // that's the case include the WWW-Authenticate challenge

        if (exc.getCode() != ResourceException.UNAUTHORIZED) {
            return;
        }

        Set<String> authChallenges = (Set<String>) request.getAttribute(Http.AUTH_CHALLENGES);
        if (authChallenges == null) {
            return;
        }

        // check if we're going to return multiple WWW-Authenticate headers
        // or combine them into a single comma separated value
        // One issue: with Kerberos curl supports auto negotiate only
        // the value is passed in a separate header

        if (SEND_MULTIPLE_WWW_AUTHENTICATE_HEADERS) {
            for (String challenge : authChallenges) {
                response.addHeader(Http.WWW_AUTHENTICATE, challenge);
            }
        } else {
            response.addHeader(Http.WWW_AUTHENTICATE, String.join(", ", authChallenges));
        }
    }

    public  ResourceContext(HttpServletRequest request, HttpServletResponse response,
            Http.AuthorityList authorities, Authorizer authorizer);

}