]> WPIA git - gigi.git/blob - src/org/cacert/gigi/pages/account/ChangePasswordPage.java
upd: use a more strict pattern for handling forms
[gigi.git] / src / org / cacert / gigi / pages / account / ChangePasswordPage.java
1 package org.cacert.gigi.pages.account;
2
3 import java.io.IOException;
4 import java.util.HashMap;
5
6 import javax.servlet.http.HttpServletRequest;
7 import javax.servlet.http.HttpServletResponse;
8
9 import org.cacert.gigi.dbObjects.User;
10 import org.cacert.gigi.output.template.Form;
11 import org.cacert.gigi.pages.Page;
12 import org.cacert.gigi.util.AuthorizationContext;
13
14 public class ChangePasswordPage extends Page {
15
16     public static final String PATH = "/account/password";
17
18     public ChangePasswordPage() {
19         super("Change Password");
20     }
21
22     @Override
23     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
24         new ChangeForm(req, getUser(req)).output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
25     }
26
27     @Override
28     public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
29         Form.getForm(req, ChangeForm.class).submitProtected(resp.getWriter(), req);
30     }
31
32     @Override
33     public boolean isPermitted(AuthorizationContext ac) {
34         return ac != null && ac.getTarget() instanceof User;
35     }
36 }