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.GigiApiException;
10 import org.cacert.gigi.dbObjects.Assurance;
11 import org.cacert.gigi.dbObjects.User;
12 import org.cacert.gigi.output.template.Form;
13 import org.cacert.gigi.pages.LoginPage;
14 import org.cacert.gigi.pages.Page;
15 import org.cacert.gigi.util.AuthorizationContext;
17 public class RequestTTPPage extends Page {
19 public static final String PATH = "/wot/ttp";
21 public RequestTTPPage() {
26 public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
28 Form.getForm(req, RequestTTPForm.class).submit(resp.getWriter(), req);
29 } catch (GigiApiException e) {
30 e.format(resp.getWriter(), getLanguage(req));
35 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
36 User u = LoginPage.getUser(req);
37 HashMap<String, Object> map = new HashMap<String, Object>();
38 if (u.isInGroup(RequestTTPForm.TTP_APPLICANT)) {
39 map.put("inProgress", true);
41 if (u.getAssurancePoints() < 100) {
43 for (Assurance a : u.getReceivedAssurances()) {
44 if (a.getMethod().equals(Assurance.AssuranceType.TTP_ASSISTED.getDescription())) {
50 map.put("form", new RequestTTPForm(req));
52 map.put("nothing", true);
55 map.put("nothing", true);
58 map.put("form", new RequestTTPForm(req));
59 getDefaultTemplate().output(resp.getWriter(), getLanguage(req), map);
63 public boolean isPermitted(AuthorizationContext ac) {
64 return ac != null && ac.getTarget() instanceof User;