X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fcacert%2Fgigi%2FGigi.java;h=cb8c389e2fae0a1b68bc640b5652e9528779aea9;hb=533294134fb42a02b2557c68eda45f47d77e73cc;hp=b80f9c7596808c63cdfe92213ea51897d14f72ba;hpb=035c67402c9c861257f0b74e18c00648425d4f31;p=gigi.git diff --git a/src/org/cacert/gigi/Gigi.java b/src/org/cacert/gigi/Gigi.java index b80f9c75..cb8c389e 100644 --- a/src/org/cacert/gigi/Gigi.java +++ b/src/org/cacert/gigi/Gigi.java @@ -21,7 +21,9 @@ 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.CATS.CATSType; import org.cacert.gigi.dbObjects.CertificateProfile; import org.cacert.gigi.dbObjects.DomainPingConfiguration; import org.cacert.gigi.localisation.Language; @@ -32,6 +34,7 @@ import org.cacert.gigi.output.SimpleMenuItem; import org.cacert.gigi.output.template.Form.CSRFException; import org.cacert.gigi.output.template.Outputable; import org.cacert.gigi.output.template.Template; +import org.cacert.gigi.pages.AboutPage; import org.cacert.gigi.pages.HandlesMixedRequest; import org.cacert.gigi.pages.LoginPage; import org.cacert.gigi.pages.LogoutPage; @@ -66,6 +69,7 @@ import org.cacert.gigi.pages.wot.MyPoints; import org.cacert.gigi.pages.wot.RequestTTPPage; import org.cacert.gigi.ping.PingerDaemon; import org.cacert.gigi.util.AuthorizationContext; +import org.cacert.gigi.util.DomainAssessment; import org.cacert.gigi.util.ServerConstants; public final class Gigi extends HttpServlet { @@ -125,6 +129,7 @@ public final class Gigi extends HttpServlet { }); putPage("/", new MainPage(), null); putPage("/roots", new RootCertPage(truststore), "SomeCA.org"); + putPage("/about", new AboutPage(), "SomeCA.org"); putPage("/secure", new TestSecure(), null); putPage(Verify.PATH, new Verify(), null); @@ -177,7 +182,7 @@ public final class Gigi extends HttpServlet { baseTemplate = new Template(Gigi.class.getResource("Gigi.templ")); rootMenu = new MenuCollector(); - 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))); } @@ -231,6 +236,7 @@ public final class Gigi extends HttpServlet { } testing = conf.getProperty("testing") != null; instance = this; + DomainAssessment.init(conf); DatabaseConnection.init(conf); this.truststore = truststore; pinger = new PingerDaemon(truststore); @@ -245,8 +251,13 @@ 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); + CATSType.ASSURER_CHALLENGE.getDisplayName(); + } catch (InterruptedException e) { + throw new Error(e); + } MenuBuilder mb = new MenuBuilder(); rootMenu = mb.generateMenu(); @@ -301,16 +312,29 @@ 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 // it always String originHeader = req.getHeader("Origin"); if (originHeader != null // - && - !(originHeader.matches("^" + Pattern.quote("https://" + ServerConstants.getWwwHostNamePortSecure()) + "(/.*|)") || // + && !(originHeader.matches("^" + Pattern.quote("https://" + ServerConstants.getWwwHostNamePortSecure()) + "(/.*|)") || // originHeader.matches("^" + Pattern.quote("http://" + ServerConstants.getWwwHostNamePort()) + "(/.*|)") || // - originHeader.matches("^" + Pattern.quote("https://" + ServerConstants.getSecureHostNamePort()) + "(/.*|)"))) { + originHeader.matches("^" + Pattern.quote("https://" + ServerConstants.getSecureHostNamePort()) + "(/.*|)"))) { resp.setContentType("text/html; charset=utf-8"); resp.getWriter().println("AlertNo cross domain access allowed.
If you don't know why you're seeing this you may have been fished! Please change your password immediately!"); return;