Ejemplo n.º 1
0
  private void check(HttpServletRequest request, HttpServletResponse response) {
    boolean authorizedIP = false;
    String remoteIP = request.getRemoteAddr();
    if ((authIPs != null) && (authIPs.length > 0)) {
      for (int i = 0; i < authIPs.length; i++) {
        if (remoteIP.equals(authIPs[i])) {
          authorizedIP = true;
        }
      }
    } else {
      String iMsg = intres.getLocalizedMessage("healthcheck.allipsauthorized");
      log.info(iMsg);
      authorizedIP = true;
    }

    if (authorizedIP) {
      getHealthResponse().respond(getHealthCheck().checkHealth(request), response);
    } else {
      if ((remoteIP == null) || (remoteIP.length() > 100)) {
        remoteIP = "unknown";
      }
      try {
        response.sendError(
            HttpServletResponse.SC_UNAUTHORIZED,
            "ERROR : Healthcheck request recieved from an non authorized IP: " + remoteIP);
      } catch (IOException e) {
        log.error("Problems generating unauthorized http response.", e);
      }
      String iMsg = intres.getLocalizedMessage("healthcheck.errorauth", remoteIP);
      log.error(iMsg);
    }
  }
Ejemplo n.º 2
0
  /**
   * Handles HTTP GET
   *
   * @param request servlet request
   * @param response servlet response
   * @throws IOException input/output error
   * @throws ServletException on error
   */
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    log.trace(">doGet()");
    response.setHeader("Allow", "POST");

    ServletDebug debug = new ServletDebug(request, response);
    String iMsg = intres.getLocalizedMessage("certreq.postonly");
    debug.print(iMsg);
    debug.printDebugInfo();
    log.trace("<doGet()");
  }