X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FGigi.java;h=3fa5d47a8313d86788f6c015830620d76cc33c0f;hb=a47365418ded7c5e8df26c2e92b76b3118a23654;hp=78924e822687909511c231cfa8dd5a52417804c3;hpb=7cf984749cf0027ccae90a53ebef07ab97ff164b;p=gigi.git diff --git a/src/org/cacert/gigi/Gigi.java b/src/org/cacert/gigi/Gigi.java index 78924e82..3fa5d47a 100644 --- a/src/org/cacert/gigi/Gigi.java +++ b/src/org/cacert/gigi/Gigi.java @@ -20,11 +20,15 @@ import org.cacert.gigi.email.EmailProvider; import org.cacert.gigi.pages.LoginPage; import org.cacert.gigi.pages.MainPage; import org.cacert.gigi.pages.Page; +import org.cacert.gigi.pages.PolicyRedir; import org.cacert.gigi.pages.TestSecure; import org.cacert.gigi.pages.Verify; +import org.cacert.gigi.pages.account.MailAdd; import org.cacert.gigi.pages.account.MailCertificates; +import org.cacert.gigi.pages.account.MailOverview; import org.cacert.gigi.pages.account.MyDetails; import org.cacert.gigi.pages.main.RegisterPage; +import org.cacert.gigi.pages.wot.AssurePage; import org.eclipse.jetty.util.log.Log; public class Gigi extends HttpServlet { @@ -44,9 +48,14 @@ public class Gigi extends HttpServlet { pages.put("/", new MainPage("CACert - Home")); pages.put("/secure", new TestSecure()); pages.put(Verify.PATH, new Verify()); + pages.put(AssurePage.PATH, new AssurePage()); pages.put(MailCertificates.PATH, new MailCertificates()); pages.put(MyDetails.PATH, new MyDetails()); pages.put(RegisterPage.PATH, new RegisterPage()); + pages.put(PolicyRedir.PATH, new PolicyRedir()); + pages.put(MailOverview.DEFAULT_PATH, new MailOverview( + "My email addresses")); + pages.put(MailAdd.DEFAULT_PATH, new MailAdd("Add new email")); String templ = ""; try (BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(new File("templates/base.html"))))) { @@ -74,8 +83,9 @@ public class Gigi extends HttpServlet { return; } - if (pages.containsKey(req.getPathInfo())) { - Page p = pages.get(req.getPathInfo()); + Page p = getPage(req.getPathInfo()); + if (p != null) { + if (p.needsLogin() && hs.getAttribute("loggedin") == null) { String request = req.getPathInfo(); request = request.split("\\?")[0]; @@ -103,6 +113,28 @@ public class Gigi extends HttpServlet { resp.sendError(404, "Page not found."); } + } + private Page getPage(String pathInfo) { + if (pathInfo.endsWith("/")) { + pathInfo = pathInfo.substring(0, pathInfo.length() - 1); + } + Page page = pages.get(pathInfo); + if (page != null) { + return page; + } + page = pages.get(pathInfo + "/*"); + if (page != null) { + return page; + } + int idx = pathInfo.lastIndexOf('/'); + pathInfo = pathInfo.substring(0, idx); + + page = pages.get(pathInfo + "/*"); + if (page != null) { + return page; + } + return null; + } private String makeDynTempl(String in, Page p) { int year = Calendar.getInstance().get(Calendar.YEAR);