]> WPIA git - gigi.git/commitdiff
ADD: Functoinality behind SE change dob and SE change name
authorJanis Streib <janis@dogcraft.de>
Sat, 21 Mar 2015 22:04:19 +0000 (23:04 +0100)
committerJanis Streib <janis@dogcraft.de>
Sat, 21 Mar 2015 22:09:38 +0000 (23:09 +0100)
src/org/cacert/gigi/dbObjects/SupportedUser.java
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.java

index 668fd8c9815a64896f33b5f41f3c272c1a359eec..58755059e27cddf15342b2513d3018881befd25d 100644 (file)
@@ -18,14 +18,22 @@ public class SupportedUser {
         this.ticket = ticket;
     }
 
-    public void setName(String fname, String mname, String lname, String suffix) throws GigiApiException {
+    public boolean setName(Name newName) throws GigiApiException {
+        if (newName.equals(target.getName())) {
+            return false;
+        }
         writeSELog("SE Name change");
-        target.setName(new Name(fname, lname, mname, suffix));
+        target.setName(newName);
+        return true;
     }
 
-    public void setDob(Date dob) throws GigiApiException {
+    public boolean setDob(Date dob) throws GigiApiException {
+        if (dob.toString().equals(target.getDoB().toString())) {
+            return false;
+        }
         writeSELog("SE dob change");
         target.setDoB(dob);
+        return true;
     }
 
     public void revokeAllCertificates() throws GigiApiException {
@@ -64,4 +72,8 @@ public class SupportedUser {
         return target;
     }
 
+    public void submitSupportAction() throws GigiApiException {
+        target.rawUpdateUserData();
+    }
+
 }
index 737a94c116b7c99fda767144fbc54d71ee2055d6..21c2183beb596fe22f3c5f8313a7b8ca3ff7240c 100644 (file)
@@ -15,12 +15,16 @@ import org.cacert.gigi.output.DateSelector;
 import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.output.template.Template;
 
+import sun.security.pkcs11.Secmod.DbMode;
+
 public class SupportUserDetailsForm extends Form {
 
     private static Template t;
 
     private SupportedUser user;
 
+    private DateSelector dobSelector;
+
     static {
         t = new Template(FindDomainForm.class.getResource("SupportUserDetailsForm.templ"));
     }
@@ -28,12 +32,30 @@ public class SupportUserDetailsForm extends Form {
     public SupportUserDetailsForm(HttpServletRequest hsr, SupportedUser user) {
         super(hsr);
         this.user = user;
+        dobSelector = new DateSelector("dobd", "dobm", "doby", user.getTargetUser().getDoB());
     }
 
     @Override
     public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException {
-
-        return false;
+        if (user.getTicket() == null) {
+            return false;
+        }
+        dobSelector.update(req);
+        String fname = req.getParameter("fname");
+        String mname = req.getParameter("mname");
+        String lname = req.getParameter("lname");
+        String suffix = req.getParameter("suffix");
+        if (fname == null || mname == null || lname == null | suffix == null) {
+            throw new GigiApiException("Incomplete request!");
+        }
+        if ( !dobSelector.isValid()) {
+            throw new GigiApiException("Invalid date of birth!");
+        }
+        Name newName = new Name(fname, lname, mname, suffix);
+        if (user.setDob(dobSelector.getDate()) | user.setName(newName)) {
+            user.submitSupportAction();
+        }
+        return true;
     }
 
     @Override
@@ -46,7 +68,7 @@ public class SupportUserDetailsForm extends Form {
         vars.put("lname", name.getLname());
         vars.put("suffix", name.getSuffix());
         vars.put("assurer", user.canAssure());
-        vars.put("dob", new DateSelector("dobd", "dobm", "doby", user.getDoB()));
+        vars.put("dob", dobSelector);
         vars.put("blockedassurer", user.isInGroup(Group.BLOCKEDASSURER));
         vars.put("codesign", user.isInGroup(Group.CODESIGNING));
         vars.put("orgassurer", user.isInGroup(Group.ORGASSURER));