Esempio n. 1
0
 private JSONAware handleSecurely(
     final ServletRequestHandler pReqHandler,
     final HttpServletRequest pReq,
     final HttpServletResponse pResp)
     throws IOException, PrivilegedActionException {
   Subject subject = (Subject) pReq.getAttribute(ConfigKey.JAAS_SUBJECT_REQUEST_ATTRIBUTE);
   if (subject != null) {
     return Subject.doAs(
         subject,
         new PrivilegedExceptionAction<JSONAware>() {
           public JSONAware run() throws IOException {
             return pReqHandler.handleRequest(pReq, pResp);
           }
         });
   } else {
     return pReqHandler.handleRequest(pReq, pResp);
   }
 }
Esempio n. 2
0
  @SuppressWarnings("PMD.AvoidCatchingThrowable")
  private void handle(
      ServletRequestHandler pReqHandler, HttpServletRequest pReq, HttpServletResponse pResp)
      throws IOException {
    JSONAware json = null;
    int code = 200;
    try {
      // Check access policy
      requestHandler.checkClientIPAccess(pReq.getRemoteHost(), pReq.getRemoteAddr());

      // Dispatch for the proper HTTP request method
      json = pReqHandler.handleRequest(pReq, pResp);
      code = requestHandler.extractResultCode(json);
      if (backendManager.isDebug()) {
        backendManager.info("Response: " + json);
      }
    } catch (Throwable exp) {
      JSONObject error = requestHandler.handleThrowable(exp);
      code = (Integer) error.get("status");
      json = error;
    } finally {
      sendResponse(pResp, code, json.toJSONString());
    }
  }