+ session = req.getSession(true);
+
+ if (req.getServerPort() == 443) http = "https"; else http = "http";
+
+ //nothing in Mir can or should be cached as it's all dynamic...
+ //
+ //this needs to be done here and not per page (via meta tags) as some
+ //browsers have problems w/ it per-page -mh
+ res.setHeader("Pragma", "no-cache");
+ res.setDateHeader("Expires", 0);
+ res.setHeader("Cache-Control", "no-cache");
+ res.setContentType("text/html; charset="
+ +MirConfig.getProp("Mir.DefaultEncoding"));
+ String moduleName = req.getParameter("module");
+
+ checkLanguage(session, req);
+
+ /** @todo for cleanup and readability this should be moved to
+ * method loginIfNecessary() */
+
+ // Authentifizierung
+ if (moduleName != null && moduleName.equals("login")) {
+ String user = req.getParameter("login");
+ String passwd = req.getParameter("password");
+ theLog.printDebugInfo("--login: evaluating for user: " + user);
+ EntityUsers userEntity = allowedUser(user, passwd);
+ if (userEntity == null) {
+ // login failed: redirecting to login
+ theLog.printWarning("--login: failed!");
+ _sendLoginPage(res, req, res.getWriter());
+ return;
+ }
+ else {
+ // login successful
+
+ theLog.printInfo("--login: successful! setting uid: " + userEntity.getId());
+ session.setAttribute("login.uid", userEntity);
+ theLog.printDebugInfo("--login: trying to retrieve login.target");
+ String target = (String) session.getAttribute("login.target");
+
+ if (target != null) {
+ theLog.printDebugInfo("Redirect: " + target);
+ int serverPort = req.getServerPort();
+ String redirect = "";
+ String redirectString = "";
+
+
+ if (serverPort == 80) {
+ redirect = res.encodeURL(http + "://" + req.getServerName() + target);
+ redirectString = "<html><head><meta http-equiv=refresh content=\"1;URL="
+ + redirect
+ + "\"></head><body>going <a href=\"" + redirect + "\">Mir</a></body></html>";
+ }
+ else {
+ redirect = res.encodeURL(http + "://" + req.getServerName() + ":" + req.getServerPort() + target);
+ redirectString = "<html><head><meta http-equiv=refresh content=\"1;URL="
+ + redirect
+ + "\"></head><body>going <a href=\"" + redirect + "\">Mir</a></body></html>";
+ }
+ res.getWriter().println(redirectString);
+
+
+ //res.sendRedirect(redirect);
+
+ }
+ else {
+ // redirecting to default target
+ theLog.printDebugInfo("--login: no target - redirecting to default");
+ _sendStartPage(res, req, res.getWriter(), userEntity);
+ }
+ return;
+ } // if login succesful
+ } // if login
+
+ if (moduleName != null && moduleName.equals("logout")) {
+ theLog.printDebugInfo("--logout");
+ session.invalidate();
+
+ //session = req.getSession(true);
+ //checkLanguage(session, req);
+ _sendLoginPage(res, req, res.getWriter());
+ return;
+ }