X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FGigi.java;h=00a10f4a34b623e9f5e22ef44fb8af3f265e4974;hb=47c7ef9db6c7a688853f338495ba61e3d827b2d2;hp=c5ee8cd3e6f9b46a2acf9f14e10f9528af156d85;hpb=4d9b0e8bdf122324cec9f3dd387c02d14c30877e;p=gigi.git diff --git a/src/org/cacert/gigi/Gigi.java b/src/org/cacert/gigi/Gigi.java index c5ee8cd3..00a10f4a 100644 --- a/src/org/cacert/gigi/Gigi.java +++ b/src/org/cacert/gigi/Gigi.java @@ -22,11 +22,8 @@ import javax.servlet.http.HttpSession; import org.cacert.gigi.database.DatabaseConnection; import org.cacert.gigi.dbObjects.CACertificate; -import org.cacert.gigi.dbObjects.CertificateOwner; import org.cacert.gigi.dbObjects.CertificateProfile; import org.cacert.gigi.dbObjects.DomainPingConfiguration; -import org.cacert.gigi.dbObjects.Organisation; -import org.cacert.gigi.dbObjects.User; import org.cacert.gigi.localisation.Language; import org.cacert.gigi.output.Menu; import org.cacert.gigi.output.PageMenuItem; @@ -46,6 +43,8 @@ import org.cacert.gigi.pages.TestSecure; import org.cacert.gigi.pages.Verify; import org.cacert.gigi.pages.account.ChangePasswordPage; import org.cacert.gigi.pages.account.MyDetails; +import org.cacert.gigi.pages.account.UserHistory; +import org.cacert.gigi.pages.account.UserTrainings; import org.cacert.gigi.pages.account.certs.CertificateAdd; import org.cacert.gigi.pages.account.certs.Certificates; import org.cacert.gigi.pages.account.domain.DomainOverview; @@ -53,6 +52,7 @@ import org.cacert.gigi.pages.account.mail.MailOverview; import org.cacert.gigi.pages.admin.TTPAdminPage; import org.cacert.gigi.pages.admin.support.FindDomainPage; import org.cacert.gigi.pages.admin.support.FindUserPage; +import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage; import org.cacert.gigi.pages.admin.support.SupportUserDetailsPage; import org.cacert.gigi.pages.error.AccessDenied; import org.cacert.gigi.pages.error.PageNotFound; @@ -106,7 +106,14 @@ public class Gigi extends HttpServlet { public Menu generateMenu() throws ServletException { putPage("/denied", new AccessDenied(), null); putPage("/error", new PageNotFound(), null); - putPage("/login", new LoginPage("Password Login"), "CAcert.org"); + putPage("/login", new LoginPage("Password Login"), null); + getMenu("CAcert.org").addItem(new SimpleMenuItem("https://" + ServerConstants.getWwwHostNamePort() + "/login", "Password Login") { + + @Override + public boolean isPermitted(AuthorizationContext ac) { + return ac == null; + } + }); getMenu("CAcert.org").addItem(new SimpleMenuItem("https://" + ServerConstants.getSecureHostNamePort() + "/login", "Certificate Login") { @Override @@ -134,7 +141,12 @@ public class Gigi extends HttpServlet { putPage(ViewOrgPage.DEFAULT_PATH + "/*", new ViewOrgPage(), "Organisation Admin"); putPage(FindUserPage.PATH, new FindUserPage("Find User"), "System Admin"); putPage(FindDomainPage.PATH, new FindDomainPage("Find Domain"), "System Admin"); + putPage(SupportEnterTicketPage.PATH, new SupportEnterTicketPage(), "System Admin"); putPage(SupportUserDetailsPage.PATH + "*", new SupportUserDetailsPage("Support: User Details"), null); + putPage(UserHistory.PATH, new UserHistory(false), "My Account"); + putPage(UserHistory.SUPPORT_PATH, new UserHistory(true), null); + putPage(UserTrainings.PATH, new UserTrainings(false), "My Account"); + putPage(UserTrainings.SUPPORT_PATH, new UserTrainings(true), null); if (testing) { try { Class manager = Class.forName("org.cacert.gigi.pages.Manager"); @@ -257,17 +269,20 @@ public class Gigi extends HttpServlet { return page; } int idx = pathInfo.lastIndexOf('/'); + if (idx == -1 || idx == 0) { + return null; + } page = pages.get(pathInfo.substring(0, idx) + "/*"); if (page != null) { return page; } - - int lIdx = pathInfo.lastIndexOf('/', idx); + int lIdx = pathInfo.lastIndexOf('/', idx - 1); if (lIdx == -1) { return null; } - page = pages.get(pathInfo.substring(0, lIdx) + "/" + pathInfo.substring(idx)); + String lastResort = pathInfo.substring(0, lIdx) + "/*" + pathInfo.substring(idx); + page = pages.get(lastResort); return page; } @@ -286,7 +301,7 @@ public class Gigi extends HttpServlet { @Override protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { - boolean isSecure = req.getServerPort() == ServerConstants.getSecurePort(); + boolean isSecure = req.isSecure(); addXSSHeaders(resp, isSecure); // Firefox only sends this, if it's a cross domain access; safari sends // it always @@ -375,14 +390,10 @@ public class Gigi extends HttpServlet { vars.put("year", Calendar.getInstance().get(Calendar.YEAR)); vars.put("content", content); if (currentAuthContext != null) { - CertificateOwner target = currentAuthContext.getTarget(); - User currentPageUser = LoginPage.getUser(req); - if (target != currentPageUser) { - vars.put("loggedInAs", ((Organisation) target).getName() + " (" + currentPageUser.getName().toString() + ")"); - } else { - vars.put("loggedInAs", currentPageUser.getName().toString()); - } + // TODO maybe move this information into the AuthContext object vars.put("loginMethod", lang.getTranslation((String) req.getSession().getAttribute(LOGIN_METHOD))); + vars.put("authContext", currentAuthContext); + } resp.setContentType("text/html; charset=utf-8"); baseTemplate.output(resp.getWriter(), lang, vars);