@Test public void testHandle() throws Exception { }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection(); connection.getRequest().setHandled(true); response.setContentType(MimeTypes.TEXT_PLAIN); Map<String, Object> errorMap = new LinkedHashMap<String, Object>(); int code = connection.getResponse().getStatus(); errorMap.put("status", code); String message = connection.getResponse().getReason(); if (message == null) { message = HttpStatus.getMessage(code); } errorMap.put("message", message); if (code == HttpServletResponse.SC_FORBIDDEN) { JwtAuthenticationProperties jwtProperties = configuration.getJwtProperties(); if (jwtProperties != null) { errorMap.put("jwtProviderUrl", jwtProperties.getAuthenticationProviderUrl() + "?" + jwtProperties.getOriginalUrlQueryParam() + "="); } } gson.toJson(errorMap, response.getWriter()); }
AmbariErrorHandler extends ErrorHandler { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection(); connection.getRequest().setHandled(true); response.setContentType(MimeTypes.TEXT_PLAIN); Map<String, Object> errorMap = new LinkedHashMap<String, Object>(); int code = connection.getResponse().getStatus(); errorMap.put("status", code); String message = connection.getResponse().getReason(); if (message == null) { message = HttpStatus.getMessage(code); } errorMap.put("message", message); if (code == HttpServletResponse.SC_FORBIDDEN) { JwtAuthenticationProperties jwtProperties = configuration.getJwtProperties(); if (jwtProperties != null) { errorMap.put("jwtProviderUrl", jwtProperties.getAuthenticationProviderUrl() + "?" + jwtProperties.getOriginalUrlQueryParam() + "="); } } gson.toJson(errorMap, response.getWriter()); } }
AmbariErrorHandler extends ErrorHandler { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection(); connection.getRequest().setHandled(true); response.setContentType(MimeTypes.TEXT_PLAIN); Map<String, Object> errorMap = new LinkedHashMap<String, Object>(); int code = connection.getResponse().getStatus(); errorMap.put("status", code); String message = connection.getResponse().getReason(); if (message == null) { message = HttpStatus.getMessage(code); } errorMap.put("message", message); if (code == HttpServletResponse.SC_FORBIDDEN) { JwtAuthenticationProperties jwtProperties = configuration.getJwtProperties(); if (jwtProperties != null) { errorMap.put("jwtProviderUrl", jwtProperties.getAuthenticationProviderUrl() + "?" + jwtProperties.getOriginalUrlQueryParam() + "="); } } gson.toJson(errorMap, response.getWriter()); } @Inject  AmbariErrorHandler(@Named("prettyGson") Gson prettyGson, Configuration configuration); }
AmbariErrorHandler extends ErrorHandler { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection(); connection.getRequest().setHandled(true); response.setContentType(MimeTypes.TEXT_PLAIN); Map<String, Object> errorMap = new LinkedHashMap<String, Object>(); int code = connection.getResponse().getStatus(); errorMap.put("status", code); String message = connection.getResponse().getReason(); if (message == null) { message = HttpStatus.getMessage(code); } errorMap.put("message", message); if (code == HttpServletResponse.SC_FORBIDDEN) { JwtAuthenticationProperties jwtProperties = configuration.getJwtProperties(); if (jwtProperties != null) { errorMap.put("jwtProviderUrl", jwtProperties.getAuthenticationProviderUrl() + "?" + jwtProperties.getOriginalUrlQueryParam() + "="); } } gson.toJson(errorMap, response.getWriter()); } @Inject  AmbariErrorHandler(@Named("prettyGson") Gson prettyGson, Configuration configuration); @Override void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response); }
AmbariErrorHandler extends ErrorHandler { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection(); connection.getRequest().setHandled(true); response.setContentType(MimeTypes.TEXT_PLAIN); Map<String, Object> errorMap = new LinkedHashMap<String, Object>(); int code = connection.getResponse().getStatus(); errorMap.put("status", code); String message = connection.getResponse().getReason(); if (message == null) { message = HttpStatus.getMessage(code); } errorMap.put("message", message); if (code == HttpServletResponse.SC_FORBIDDEN) { JwtAuthenticationProperties jwtProperties = configuration.getJwtProperties(); if (jwtProperties != null) { errorMap.put("jwtProviderUrl", jwtProperties.getAuthenticationProviderUrl() + "?" + jwtProperties.getOriginalUrlQueryParam() + "="); } } gson.toJson(errorMap, response.getWriter()); } @Inject  AmbariErrorHandler(@Named("prettyGson") Gson prettyGson, Configuration configuration); @Override void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response);  }