add: enable support to search for certificates
[gigi.git] / src / org / cacert / gigi / pages / account / certs / RevokeSingleCertForm.java
1 package org.cacert.gigi.pages.account.certs;
2
3 import java.io.PrintWriter;
4 import java.util.Map;
5
6 import javax.servlet.http.HttpServletRequest;
7
8 import org.cacert.gigi.GigiApiException;
9 import org.cacert.gigi.dbObjects.Certificate;
10 import org.cacert.gigi.dbObjects.SupportedUser;
11 import org.cacert.gigi.localisation.Language;
12 import org.cacert.gigi.output.template.Form;
13 import org.cacert.gigi.output.template.Template;
14
15 public class RevokeSingleCertForm extends Form {
16
17     private static final Template t = new Template(RevokeSingleCertForm.class.getResource("RevokeSingleCertForm.templ"));
18
19     private Certificate c;
20
21     private SupportedUser target;
22
23     public RevokeSingleCertForm(HttpServletRequest hsr, Certificate c, SupportedUser target) {
24         super(hsr);
25         this.c = c;
26         this.target = target;
27     }
28
29     @Override
30     public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException {
31         if (target != null) {
32             target.revokeCertificate(c);
33         } else {
34             c.revoke().waitFor(60000);
35         }
36         return true;
37     }
38
39     @Override
40     protected void outputContent(PrintWriter out, Language l, Map<String, Object> vars) {
41         t.output(out, l, vars);
42     }
43
44 }