1 package org.cacert.gigi.pages.wot;
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.Assurance;
10 import org.cacert.gigi.dbObjects.User;
11 import org.cacert.gigi.output.template.Form;
12 import org.cacert.gigi.pages.LoginPage;
13 import org.cacert.gigi.pages.Page;
14 import org.cacert.gigi.util.AuthorizationContext;
16 public class RequestTTPPage extends Page {
18 public static final String PATH = "/wot/ttp";
20 public RequestTTPPage() {
25 public boolean beforePost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
26 return Form.getForm(req, RequestTTPForm.class).submitExceptionProtected(req, resp);
30 public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
31 if (Form.printFormErrors(req, resp.getWriter())) {
32 Form.getForm(req, RequestTTPForm.class).output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
37 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
38 User u = LoginPage.getUser(req);
39 HashMap<String, Object> map = new HashMap<String, Object>();
40 if (u.isInGroup(RequestTTPForm.TTP_APPLICANT)) {
41 map.put("inProgress", true);
43 if (u.getAssurancePoints() < 100) {
45 for (Assurance a : u.getReceivedAssurances()) {
46 if (a.getMethod().equals(Assurance.AssuranceType.TTP_ASSISTED.getDescription())) {
52 map.put("form", new RequestTTPForm(req));
54 map.put("nothing", true);
57 map.put("nothing", true);
60 map.put("form", new RequestTTPForm(req));
61 getDefaultTemplate().output(resp.getWriter(), getLanguage(req), map);
65 public boolean isPermitted(AuthorizationContext ac) {
66 return ac != null && ac.getTarget() instanceof User;