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.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 {
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"));
String templ = "";
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
new FileInputStream(new File("templates/base.html"))))) {
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];
resp.sendError(404, "Page not found.");
}
+ }
+ private Page getPage(String pathInfo) {
+
+ 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);