From: Janis Streib Date: Sat, 21 Mar 2015 22:04:19 +0000 (+0100) Subject: ADD: Functoinality behind SE change dob and SE change name X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=222dad8ea970f35d8ed79dfd445c5b301ff2fb92 ADD: Functoinality behind SE change dob and SE change name --- diff --git a/src/org/cacert/gigi/dbObjects/SupportedUser.java b/src/org/cacert/gigi/dbObjects/SupportedUser.java index 668fd8c9..58755059 100644 --- a/src/org/cacert/gigi/dbObjects/SupportedUser.java +++ b/src/org/cacert/gigi/dbObjects/SupportedUser.java @@ -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(); + } + } diff --git a/src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.java b/src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.java index 737a94c1..21c2183b 100644 --- a/src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.java +++ b/src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.java @@ -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));