X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FGigi.java;h=b6cb3d7fe5f161b24d9bbd4b05c73fd3b080581f;hp=5fda72d045597cb507ddace05197363c2b6893df;hb=d23d7a6fa9dc38c6193fea70017e0bff11257be5;hpb=bd738ff4450f7fabe08c4ca5bd3f7597d0b011ef diff --git a/src/org/cacert/gigi/Gigi.java b/src/org/cacert/gigi/Gigi.java index 5fda72d0..b6cb3d7f 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; 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; @@ -125,6 +128,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); @@ -245,8 +249,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); + CATS.getID(CATS.ASSURER_CHALLENGE_NAME); + } catch (InterruptedException e) { + throw new Error(e); + } MenuBuilder mb = new MenuBuilder(); rootMenu = mb.generateMenu(); @@ -301,16 +310,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;