1 package org.cacert.gigi.pages.account;
3 import java.io.IOException;
4 import java.util.HashMap;
6 import javax.servlet.http.HttpServletRequest;
7 import javax.servlet.http.HttpServletResponse;
9 import org.cacert.gigi.dbObjects.CertificateOwner;
10 import org.cacert.gigi.dbObjects.User;
11 import org.cacert.gigi.output.template.OutputableArrayIterable;
12 import org.cacert.gigi.pages.LoginPage;
13 import org.cacert.gigi.pages.Page;
14 import org.cacert.gigi.util.AuthorizationContext;
16 public class History extends Page {
18 public static final String SUPPORT_PATH = "/support/user/*/history";
20 public static final String PATH = "/account/history";
22 private static final int intStart = SUPPORT_PATH.indexOf('*');
24 private boolean support;
26 public History(boolean support) {
27 super(support ? "Support History" : "History");
28 this.support = support;
32 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
35 String info = req.getPathInfo();
36 int id = Integer.parseInt(info.substring(intStart, info.length() - SUPPORT_PATH.length() + intStart + 1));
43 u = LoginPage.getAuthorizationContext(req).getTarget();
45 String[] adminLog = u.getAdminLog();
46 HashMap<String, Object> vars = new HashMap<>();
47 vars.put("entries", new OutputableArrayIterable(adminLog, "entry"));
48 getDefaultTemplate().output(resp.getWriter(), getLanguage(req), vars);
52 public boolean isPermitted(AuthorizationContext ac) {
53 return ac != null && ( !support || ac.canSupport());