Example #1
0
 private void invalidateCookies(HttpServletRequest request, HttpServletResponse response) {
   Cookie[] c = request.getCookies();
   for (Cookie cookie : c) {
     cookie.setMaxAge(0);
     LOGGER.info(TextUtils.merge("Invalidate cookie: {0}", cookie.getName()));
     response.addCookie(cookie);
   }
 }
Example #2
0
 @Override
 protected void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   HttpSession session = request.getSession(false);
   if (session != null) {
     RAPSupport.setLoggedInUser(new UserPrincipal("none"));
     HttpSessionManager.removeStoredHttpSession(session.getId());
     invalidateCookies(request, response);
     redirectLoginPage(response);
     LOGGER.log(
         Level.INFO, TextUtils.merge("Logout from httpSessionId: {0} performed", session.getId()));
   }
 }
Example #3
0
  public static void setup(LoggerConfig config) {
    Logger log = config.getRootLogger();

    DefaultFormatter.setAppId(config.getLogFileName());

    try {
      File logDir = Directories.getLogDir();
      if (!logDir.exists()) {
        logDir.mkdirs();
      }

      FileHandler fileHandler =
          new FileHandler(
              config.getLogFilePattern(),
              config.getMaxBytes(),
              config.getMaxFiles(),
              config.doAppend());
      LogManager manager = LogManager.getLogManager();

      // retrieve the Level-setting from the property file for the FileHandler
      Level level = Level.ALL;
      String val = manager.getProperty(FileHandler.class.getName() + ".level");
      if (val != null) {
        try {
          level = Level.parse(val.trim());
        } catch (Exception ex) {
        }
      }
      fileHandler.setLevel(level);
      log.addHandler(fileHandler);
    } catch (Exception e) {
      System.err.println(
          TextUtils.merge(
              "Unable to setup log file for ''{0}''. Reason: {1}",
              config.getLogFileName(), e.getLocalizedMessage()));
    }

    for (Handler handler : log.getHandlers()) {
      handler.setFormatter(config.getFormatter());

      // ugly hack: don't display this error message in the console until we
      // get feedback from tomcat-users mailing list,
      // see http://mail-archives.apache.org/mod_mbox/tomcat-users/201104.mbox/browser
      if (handler instanceof ConsoleHandler) {
        handler.setFilter(
            new Filter() {

              @Override
              public boolean isLoggable(LogRecord record) {
                if (record.getMessage().equals("persistentManager.swapInInvalid")) {
                  return false;
                }

                return true;
              }
            });
      }
    }

    // report this even when in WARN-loglevel
    Logger initLOGGER = Logger.getLogger("Init");
    Level level = initLOGGER.getLevel();
    try {
      initLOGGER.setLevel(Level.INFO);
      initLOGGER.info(
          "-----------------------------------------------------------------------------");
      initLOGGER.info(
          TextUtils.merge(
              "easyTravel Demo Application - Copyright (C) 2010-{0,date,yyyy} dynaTrace software GmbH",
              new Date()));
      initLOGGER.info(
          "-----------------------------------------------------------------------------");

      Version version = Version.read();
      initLOGGER.info("Version: " + version.toString());
      initLOGGER.info("Build Date: " + version.getBuilddate());
      initLOGGER.info("Platform: " + getPlatformDescription());
    } finally {
      // restore previous level
      initLOGGER.setLevel(level);
    }
  }