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;
pages.put(MailCertificates.PATH, new MailCertificates());
pages.put(MyDetails.PATH, new MyDetails());
pages.put(RegisterPage.PATH, new RegisterPage());
+ pages.put(PolicyRedir.PATH, new PolicyRedir());
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);