X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FGigi.java;h=bf6c32edc2404126276fcf140842cb18f80a0cab;hp=36afac6fe43d1f32b53ec5f6af13f6a02a616d6b;hb=d7be034f96e06985f57d86d2779c434276b5bd4d;hpb=4ef7ef003efbb904af6d4bce0ea0ee1b5091b65f diff --git a/src/org/cacert/gigi/Gigi.java b/src/org/cacert/gigi/Gigi.java index 36afac6f..bf6c32ed 100644 --- a/src/org/cacert/gigi/Gigi.java +++ b/src/org/cacert/gigi/Gigi.java @@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.cacert.gigi.database.DatabaseConnection; +import org.cacert.gigi.database.DatabaseConnection.Link; import org.cacert.gigi.dbObjects.CACertificate; import org.cacert.gigi.dbObjects.CertificateProfile; import org.cacert.gigi.dbObjects.DomainPingConfiguration; @@ -38,7 +39,6 @@ import org.cacert.gigi.pages.LogoutPage; import org.cacert.gigi.pages.MainPage; import org.cacert.gigi.pages.Page; import org.cacert.gigi.pages.PasswordResetPage; -import org.cacert.gigi.pages.PolicyIndex; import org.cacert.gigi.pages.RootCertPage; import org.cacert.gigi.pages.StaticPage; import org.cacert.gigi.pages.TestSecure; @@ -109,7 +109,7 @@ public final class Gigi extends HttpServlet { public MenuCollector generateMenu() throws ServletException { putPage("/denied", new AccessDenied(), null); putPage("/error", new PageNotFound(), null); - putPage("/login", new LoginPage("Password Login"), null); + putPage("/login", new LoginPage(), null); getMenu("SomeCA.org").addItem(new SimpleMenuItem("https://" + ServerConstants.getWwwHostNamePort() + "/login", "Password Login") { @Override @@ -124,7 +124,7 @@ public final class Gigi extends HttpServlet { return ac == null; } }); - putPage("/", new MainPage("SomeCA - Home"), null); + putPage("/", new MainPage(), null); putPage("/roots", new RootCertPage(truststore), "SomeCA.org"); putPage("/secure", new TestSecure(), null); @@ -132,11 +132,11 @@ public final class Gigi extends HttpServlet { putPage(Certificates.PATH + "/*", new Certificates(), "Certificates"); putPage(RegisterPage.PATH, new RegisterPage(), "SomeCA.org"); putPage(CertificateAdd.PATH, new CertificateAdd(), "Certificates"); - putPage(MailOverview.DEFAULT_PATH, new MailOverview("Email addresses"), "Certificates"); - putPage(DomainOverview.PATH + "*", new DomainOverview("Domains"), "Certificates"); + putPage(MailOverview.DEFAULT_PATH, new MailOverview(), "Certificates"); + putPage(DomainOverview.PATH + "*", new DomainOverview(), "Certificates"); putPage(AssurePage.PATH + "/*", new AssurePage(), "Web of Trust"); - putPage(MyPoints.PATH, new MyPoints("My Points"), "Web of Trust"); + putPage(MyPoints.PATH, new MyPoints(), "Web of Trust"); putPage(MyListingPage.PATH, new MyListingPage(), "Web of Trust"); putPage(RequestTTPPage.PATH, new RequestTTPPage(), "Web of Trust"); @@ -145,12 +145,12 @@ public final class Gigi extends HttpServlet { putPage(ViewOrgPage.DEFAULT_PATH + "/*", new ViewOrgPage(), "Organisation Admin"); putPage(SupportEnterTicketPage.PATH, new SupportEnterTicketPage(), "Support Console"); - putPage(FindUserPage.PATH, new FindUserPage("Find User"), "Support Console"); - putPage(FindDomainPage.PATH, new FindDomainPage("Find Domain"), "Support Console"); + putPage(FindUserPage.PATH, new FindUserPage(), "Support Console"); + putPage(FindDomainPage.PATH, new FindDomainPage(), "Support Console"); - putPage(SupportUserDetailsPage.PATH + "*", new SupportUserDetailsPage("Support: User Details"), null); + putPage(SupportUserDetailsPage.PATH + "*", new SupportUserDetailsPage(), null); putPage(ChangePasswordPage.PATH, new ChangePasswordPage(), "My Account"); - putPage(LogoutPage.PATH, new LogoutPage("Logout"), "My Account"); + putPage(LogoutPage.PATH, new LogoutPage(), "My Account"); putPage(History.PATH, new History(false), "My Account"); putPage(History.SUPPORT_PATH, new History(true), null); putPage(UserTrainings.PATH, new UserTrainings(false), "My Account"); @@ -177,20 +177,8 @@ public final class Gigi extends HttpServlet { } baseTemplate = new Template(Gigi.class.getResource("Gigi.templ")); rootMenu = new MenuCollector(); - Menu about = new Menu("About SomeCA.org"); - categories.add(about); - - about.addItem(new SimpleMenuItem("//blog.cacert.org/", "SomeCA News")); - about.addItem(new SimpleMenuItem("//wiki.cacert.org/", "Wiki Documentation")); - putPage(PolicyIndex.DEFAULT_PATH, new PolicyIndex(), "About SomeCA.org"); - about.addItem(new SimpleMenuItem("//wiki.cacert.org/FAQ/Privileges", "Point System")); - about.addItem(new SimpleMenuItem("//bugs.cacert.org/", "Bug Database")); - about.addItem(new SimpleMenuItem("//wiki.cacert.org/Board", "SomeCA Board")); - about.addItem(new SimpleMenuItem("//lists.cacert.org/wws", "Mailing Lists")); - about.addItem(new SimpleMenuItem("//blog.SomeCA.org/feed", "RSS News Feed")); - about.addItem(new SimpleMenuItem("//wiki.cacert.org/Impress", "Impress")); - - Menu languages = new Menu("Translations"); + + Menu languages = new Menu("Language"); for (Locale l : Language.getSupportedLocales()) { languages.addItem(new SimpleMenuItem("?lang=" + l.toString(), l.getDisplayName(l))); } @@ -258,8 +246,12 @@ public final class Gigi extends HttpServlet { return; } // ensure those static initializers are finished - CACertificate.getById(1); - CertificateProfile.getById(1); + try (Link l = DatabaseConnection.newLink(false)) { + CACertificate.getById(1); + CertificateProfile.getById(1); + } catch (InterruptedException e) { + throw new Error(e); + } MenuBuilder mb = new MenuBuilder(); rootMenu = mb.generateMenu(); @@ -314,6 +306,20 @@ public final class Gigi extends HttpServlet { @Override protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { + if ("/error".equals(req.getPathInfo()) || "/denied".equals(req.getPathInfo())) { + if (DatabaseConnection.hasInstance()) { + serviceWithConnection(req, resp); + return; + } + } + try (DatabaseConnection.Link l = DatabaseConnection.newLink( !req.getMethod().equals("POST"))) { + serviceWithConnection(req, resp); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + protected void serviceWithConnection(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { boolean isSecure = req.isSecure(); addXSSHeaders(resp, isSecure); // Firefox only sends this, if it's a cross domain access; safari sends @@ -406,7 +412,7 @@ public final class Gigi extends HttpServlet { vars.put("content", content); if (currentAuthContext != null) { // TODO maybe move this information into the AuthContext object - vars.put("loginMethod", lang.getTranslation((String) req.getSession().getAttribute(LOGIN_METHOD))); + vars.put("loginMethod", req.getSession().getAttribute(LOGIN_METHOD)); vars.put("authContext", currentAuthContext); } @@ -443,7 +449,7 @@ public final class Gigi extends HttpServlet { csp.append(";script-src https://" + ServerConstants.getStaticHostNamePortSecure()); csp.append(";style-src https://" + ServerConstants.getStaticHostNamePortSecure()); csp.append(";form-action https://" + ServerConstants.getSecureHostNamePort() + " https://" + ServerConstants.getWwwHostNamePortSecure()); - csp.append(";report-url https://api.cacert.org/security/csp/report"); + // csp.append(";report-url https://api.cacert.org/security/csp/report"); return csp.toString(); } @@ -456,7 +462,7 @@ public final class Gigi extends HttpServlet { csp.append(";script-src http://" + ServerConstants.getStaticHostNamePort()); csp.append(";style-src http://" + ServerConstants.getStaticHostNamePort()); csp.append(";form-action https://" + ServerConstants.getSecureHostNamePort() + " https://" + ServerConstants.getWwwHostNamePort()); - csp.append(";report-url http://api.cacert.org/security/csp/report"); + // csp.append(";report-url http://api.cacert.org/security/csp/report"); return csp.toString(); }