import org.cacert.gigi.database.DatabaseConnection;
import org.cacert.gigi.dbObjects.CACertificate;
-import org.cacert.gigi.dbObjects.CertificateOwner;
import org.cacert.gigi.dbObjects.CertificateProfile;
import org.cacert.gigi.dbObjects.DomainPingConfiguration;
-import org.cacert.gigi.dbObjects.Organisation;
-import org.cacert.gigi.dbObjects.User;
import org.cacert.gigi.localisation.Language;
import org.cacert.gigi.output.Menu;
import org.cacert.gigi.output.PageMenuItem;
import org.cacert.gigi.pages.LogoutPage;
import org.cacert.gigi.pages.MainPage;
import org.cacert.gigi.pages.Page;
+import org.cacert.gigi.pages.PasswordResetPage;
import org.cacert.gigi.pages.PolicyIndex;
import org.cacert.gigi.pages.RootCertPage;
import org.cacert.gigi.pages.StaticPage;
import org.cacert.gigi.pages.TestSecure;
import org.cacert.gigi.pages.Verify;
import org.cacert.gigi.pages.account.ChangePasswordPage;
+import org.cacert.gigi.pages.account.History;
import org.cacert.gigi.pages.account.MyDetails;
+import org.cacert.gigi.pages.account.UserTrainings;
import org.cacert.gigi.pages.account.certs.CertificateAdd;
import org.cacert.gigi.pages.account.certs.Certificates;
import org.cacert.gigi.pages.account.domain.DomainOverview;
import org.cacert.gigi.pages.admin.TTPAdminPage;
import org.cacert.gigi.pages.admin.support.FindDomainPage;
import org.cacert.gigi.pages.admin.support.FindUserPage;
+import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage;
import org.cacert.gigi.pages.admin.support.SupportUserDetailsPage;
import org.cacert.gigi.pages.error.AccessDenied;
import org.cacert.gigi.pages.error.PageNotFound;
import org.cacert.gigi.pages.orga.CreateOrgPage;
import org.cacert.gigi.pages.orga.ViewOrgPage;
import org.cacert.gigi.pages.wot.AssurePage;
+import org.cacert.gigi.pages.wot.MyListingPage;
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.ServerConstants;
-public class Gigi extends HttpServlet {
+public final class Gigi extends HttpServlet {
private class MenuBuilder {
public Menu generateMenu() throws ServletException {
putPage("/denied", new AccessDenied(), null);
putPage("/error", new PageNotFound(), null);
- putPage("/login", new LoginPage("Password Login"), "CAcert.org");
+ putPage("/login", new LoginPage("Password Login"), null);
+ getMenu("CAcert.org").addItem(new SimpleMenuItem("https://" + ServerConstants.getWwwHostNamePort() + "/login", "Password Login") {
+
+ @Override
+ public boolean isPermitted(AuthorizationContext ac) {
+ return ac == null;
+ }
+ });
getMenu("CAcert.org").addItem(new SimpleMenuItem("https://" + ServerConstants.getSecureHostNamePort() + "/login", "Certificate Login") {
@Override
putPage(LogoutPage.PATH, new LogoutPage("Logout"), "My Account");
putPage("/secure", new TestSecure(), null);
putPage(Verify.PATH, new Verify(), null);
- putPage(AssurePage.PATH + "/*", new AssurePage(), "Web of Trust");
putPage(Certificates.PATH + "/*", new Certificates(), "Certificates");
putPage(MyDetails.PATH, new MyDetails(), "My Account");
putPage(RegisterPage.PATH, new RegisterPage(), "CAcert.org");
putPage(CertificateAdd.PATH, new CertificateAdd(), "Certificates");
- putPage(MailOverview.DEFAULT_PATH, new MailOverview("My email addresses"), "Certificates");
+ putPage(MailOverview.DEFAULT_PATH, new MailOverview("Email addresses"), "Certificates");
putPage(DomainOverview.PATH + "*", new DomainOverview("Domains"), "Certificates");
+
+ putPage(AssurePage.PATH + "/*", new AssurePage(), "Web of Trust");
putPage(MyPoints.PATH, new MyPoints("My Points"), "Web of Trust");
+ putPage(MyListingPage.PATH, new MyListingPage(), "Web of Trust");
putPage(RequestTTPPage.PATH, new RequestTTPPage(), "Web of Trust");
+
putPage(TTPAdminPage.PATH + "/*", new TTPAdminPage(), "Admin");
putPage(CreateOrgPage.DEFAULT_PATH, new CreateOrgPage(), "Organisation Admin");
putPage(ViewOrgPage.DEFAULT_PATH + "/*", new ViewOrgPage(), "Organisation Admin");
- putPage(FindUserPage.PATH, new FindUserPage("Find User"), "System Admin");
- putPage(FindDomainPage.PATH, new FindDomainPage("Find Domain"), "System Admin");
+
+ putPage(SupportEnterTicketPage.PATH, new SupportEnterTicketPage(), "Support Console");
+ putPage(FindUserPage.PATH, new FindUserPage("Find User"), "Support Console");
+ putPage(FindDomainPage.PATH, new FindDomainPage("Find Domain"), "Support Console");
+
putPage(SupportUserDetailsPage.PATH + "*", new SupportUserDetailsPage("Support: User Details"), null);
+ putPage(History.PATH, new History(false), "My Account");
+ putPage(History.SUPPORT_PATH, new History(true), null);
+ putPage(UserTrainings.PATH, new UserTrainings(false), "My Account");
+ putPage(UserTrainings.SUPPORT_PATH, new UserTrainings(true), null);
+
+ putPage(PasswordResetPage.PATH, new PasswordResetPage(), null);
+
if (testing) {
try {
Class<?> manager = Class.forName("org.cacert.gigi.pages.Manager");
return page;
}
int idx = pathInfo.lastIndexOf('/');
+ if (idx == -1 || idx == 0) {
+ return null;
+ }
page = pages.get(pathInfo.substring(0, idx) + "/*");
if (page != null) {
return page;
}
-
- int lIdx = pathInfo.lastIndexOf('/', idx);
+ int lIdx = pathInfo.lastIndexOf('/', idx - 1);
if (lIdx == -1) {
return null;
}
- page = pages.get(pathInfo.substring(0, lIdx) + "/" + pathInfo.substring(idx));
+ String lastResort = pathInfo.substring(0, lIdx) + "/*" + pathInfo.substring(idx);
+ page = pages.get(lastResort);
return page;
}
@Override
protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
- boolean isSecure = req.getServerPort() == ServerConstants.getSecurePort();
+ boolean isSecure = req.isSecure();
addXSSHeaders(resp, isSecure);
// Firefox only sends this, if it's a cross domain access; safari sends
// it always
return;
}
HashMap<String, Object> vars = new HashMap<String, Object>();
+ // System.out.println(req.getMethod() + ": " + req.getPathInfo() +
+ // " -> " + p);
Outputable content = new Outputable() {
@Override
vars.put("year", Calendar.getInstance().get(Calendar.YEAR));
vars.put("content", content);
if (currentAuthContext != null) {
- CertificateOwner target = currentAuthContext.getTarget();
- User currentPageUser = LoginPage.getUser(req);
- if (target != currentPageUser) {
- vars.put("loggedInAs", ((Organisation) target).getName() + " (" + currentPageUser.getName().toString() + ")");
- } else {
- vars.put("loggedInAs", currentPageUser.getName().toString());
- }
+ // TODO maybe move this information into the AuthContext object
vars.put("loginMethod", lang.getTranslation((String) req.getSession().getAttribute(LOGIN_METHOD)));
+ vars.put("authContext", currentAuthContext);
+
}
resp.setContentType("text/html; charset=utf-8");
baseTemplate.output(resp.getWriter(), lang, vars);