@Test public void shouldUpdateCallbackFromRequest() throws RestAuthCallbackHandlerResponseException { HttpHeaders headers = mock(HttpHeaders.class); HttpServletRequest request = mock(HttpServletRequest.class); HttpServletResponse response = mock(HttpServletResponse.class); HttpCallback httpCallback = mock(HttpCallback.class); given(httpCallback.getAuthorizationHeader()).willReturn("AUTHORIZATION"); given(request.getHeader("AUTHORIZATION")).willReturn("HTTP_AUTHZ"); boolean updated = restAuthHttpCallbackHandler.updateCallbackFromRequest(headers, request, response, httpCallback); verify(httpCallback).setAuthorization("HTTP_AUTHZ"); assertTrue(updated); }
public boolean updateCallbackFromRequest(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, HttpCallback callback) throws RestAuthCallbackHandlerResponseException { String httpAuthorization = request.getHeader(callback.getAuthorizationHeader()); if (httpAuthorization == null || "".equals(httpAuthorization)) { DEBUG.message("Authorization Header not set in request."); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("failure", true) .put("reason", HTTP_AUTH_FAILED) .build(); Map<String, String> responseHeaders = new HashMap<String, String>(); responseHeaders.put(callback.getNegotiationHeaderName(), callback.getNegotiationHeaderValue()); throw new RestAuthCallbackHandlerResponseException(Response.Status.UNAUTHORIZED, responseHeaders, jsonValue); } callback.setAuthorization(httpAuthorization); return true; }
RestAuthHttpCallbackHandler extends AbstractRestAuthCallbackHandler<HttpCallback> { public boolean updateCallbackFromRequest(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, HttpCallback callback) throws RestAuthCallbackHandlerResponseException { String httpAuthorization = request.getHeader(callback.getAuthorizationHeader()); if (httpAuthorization == null || "".equals(httpAuthorization)) { DEBUG.message("Authorization Header not set in request."); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("failure", true) .put("reason", HTTP_AUTH_FAILED) .build(); Map<String, String> responseHeaders = new HashMap<String, String>(); responseHeaders.put(callback.getNegotiationHeaderName(), callback.getNegotiationHeaderValue()); throw new RestAuthCallbackHandlerResponseException(Response.Status.UNAUTHORIZED, responseHeaders, jsonValue); } callback.setAuthorization(httpAuthorization); return true; } }
RestAuthHttpCallbackHandler extends AbstractRestAuthCallbackHandler<HttpCallback> { public boolean updateCallbackFromRequest(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, HttpCallback callback) throws RestAuthCallbackHandlerResponseException { String httpAuthorization = request.getHeader(callback.getAuthorizationHeader()); if (httpAuthorization == null || "".equals(httpAuthorization)) { DEBUG.message("Authorization Header not set in request."); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("failure", true) .put("reason", HTTP_AUTH_FAILED) .build(); Map<String, String> responseHeaders = new HashMap<String, String>(); responseHeaders.put(callback.getNegotiationHeaderName(), callback.getNegotiationHeaderValue()); throw new RestAuthCallbackHandlerResponseException(Response.Status.UNAUTHORIZED, responseHeaders, jsonValue); } callback.setAuthorization(httpAuthorization); return true; }  }
RestAuthHttpCallbackHandler extends AbstractRestAuthCallbackHandler<HttpCallback> { public boolean updateCallbackFromRequest(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, HttpCallback callback) throws RestAuthCallbackHandlerResponseException { String httpAuthorization = request.getHeader(callback.getAuthorizationHeader()); if (httpAuthorization == null || "".equals(httpAuthorization)) { DEBUG.message("Authorization Header not set in request."); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("failure", true) .put("reason", HTTP_AUTH_FAILED) .build(); Map<String, String> responseHeaders = new HashMap<String, String>(); responseHeaders.put(callback.getNegotiationHeaderName(), callback.getNegotiationHeaderValue()); throw new RestAuthCallbackHandlerResponseException(Response.Status.UNAUTHORIZED, responseHeaders, jsonValue); } callback.setAuthorization(httpAuthorization); return true; }  boolean updateCallbackFromRequest(HttpHeaders headers, HttpServletRequest request,
            HttpServletResponse response, HttpCallback callback); HttpCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, HttpCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(HttpCallback callback, int index); HttpCallback convertFromJson(HttpCallback callback, JsonValue jsonCallback); }
RestAuthHttpCallbackHandler extends AbstractRestAuthCallbackHandler<HttpCallback> { public boolean updateCallbackFromRequest(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, HttpCallback callback) throws RestAuthCallbackHandlerResponseException { String httpAuthorization = request.getHeader(callback.getAuthorizationHeader()); if (httpAuthorization == null || "".equals(httpAuthorization)) { DEBUG.message("Authorization Header not set in request."); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("failure", true) .put("reason", HTTP_AUTH_FAILED) .build(); Map<String, String> responseHeaders = new HashMap<String, String>(); responseHeaders.put(callback.getNegotiationHeaderName(), callback.getNegotiationHeaderValue()); throw new RestAuthCallbackHandlerResponseException(Response.Status.UNAUTHORIZED, responseHeaders, jsonValue); } callback.setAuthorization(httpAuthorization); return true; }  boolean updateCallbackFromRequest(HttpHeaders headers, HttpServletRequest request,
            HttpServletResponse response, HttpCallback callback); HttpCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, HttpCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(HttpCallback callback, int index); HttpCallback convertFromJson(HttpCallback callback, JsonValue jsonCallback);  }