add: add boolean to separate groups for user and support
authorINOPIAE <m.maengel@inopiae.de>
Fri, 19 Aug 2016 08:43:07 +0000 (10:43 +0200)
committerFelix Dörre <felix@dogcraft.de>
Fri, 19 Aug 2016 20:59:14 +0000 (22:59 +0200)
Change-Id: I1482a77d8549178ad8413bab6ad29dac30c50b31

src/org/cacert/gigi/dbObjects/Group.java
src/org/cacert/gigi/output/GroupSelector.java
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.java

index e85b827..6e25079 100644 (file)
@@ -6,26 +6,34 @@ import org.cacert.gigi.output.template.Outputable;
 import org.cacert.gigi.output.template.TranslateCommand;
 
 public enum Group {
-    SUPPORTER("supporter", "supporter"), ARBITRATOR("arbitrator", "arbitrator"), //
-    BLOCKEDASSURER("blockedassurer", "may not verify"), BLOCKEDASSUREE("blockedassuree", "may not be verified"), //
-    BLOCKEDLOGIN("blockedlogin", "may not login"), BLOCKEDCERT("blockedcert", "may not issue certificates"), //
-    TTP_ASSURER("ttp-assurer", "may verify via TTP"), TTP_APPLICANT("ttp-applicant", "requests to be verified via ttp"), //
-    CODESIGNING("codesigning", "may issue codesigning certificates"), ORGASSURER("orgassurer", "may verify organisations"), //
-    NUCLEUS_ASSURER("nucleus-assurer", "may enter nucleus verifications"), LOCATE_AGENT("locate-agent", "wants access to the locate agent system");
+    SUPPORTER("supporter", "supporter", true), ARBITRATOR("arbitrator", "arbitrator", true), //
+    BLOCKEDASSURER("blockedassurer", "may not verify", true), BLOCKEDASSUREE("blockedassuree", "may not be verified", true), //
+    BLOCKEDLOGIN("blockedlogin", "may not login", true), BLOCKEDCERT("blockedcert", "may not issue certificates", true), //
+    TTP_ASSURER("ttp-assurer", "may verify via TTP", true), TTP_APPLICANT("ttp-applicant", "requests to be verified via ttp", true), //
+    CODESIGNING("codesigning", "may issue codesigning certificates", true), ORGASSURER("orgassurer", "may verify organisations", true), //
+    NUCLEUS_ASSURER("nucleus-assurer", "may enter nucleus verifications", true), LOCATE_AGENT("locate-agent", "wants access to the locate agent system", false);
 
     private final String dbName;
 
     private final TranslateCommand tc;
 
-    private Group(String name, String display) {
+    private final boolean managedBySupport; // true if flag is handled by
+                                            // support, false if handled by user
+
+    private Group(String name, String display, boolean managedBySupport) {
         dbName = name;
         tc = new TranslateCommand(display);
+        this.managedBySupport = managedBySupport;
     }
 
     public static Group getByString(String name) {
         return valueOf(name.toUpperCase().replace('-', '_'));
     }
 
+    public boolean isManagedBySupport() {
+        return managedBySupport;
+    }
+
     public String getDatabaseName() {
         return dbName;
     }
index a26be9b..f65fab7 100644 (file)
@@ -13,12 +13,15 @@ import org.cacert.gigi.util.HTMLEncoder;
 
 public class GroupSelector implements Outputable {
 
-    String name;
+    private final String name;
 
-    Group value = null;
+    private Group value = null;
 
-    public GroupSelector(String name) {
+    private final boolean supportFlag;
+
+    public GroupSelector(String name, boolean supportFlag) {
         this.name = HTMLEncoder.encodeHTML(name);
+        this.supportFlag = supportFlag;
     }
 
     public void update(HttpServletRequest r) throws GigiApiException {
@@ -35,11 +38,13 @@ public class GroupSelector implements Outputable {
     public void output(PrintWriter out, Language l, Map<String, Object> vars) {
         out.println("<select name='" + name + "'>");
         for (Group g : Group.values()) {
-            out.print("<option name='" + g.getDatabaseName());
-            if (g.equals(value)) {
-                out.print(" selected");
+            if (supportFlag == g.isManagedBySupport()) {
+                out.print("<option name='" + g.getDatabaseName());
+                if (g.equals(value)) {
+                    out.print(" selected");
+                }
+                out.println("'>" + g.getDatabaseName() + "</option>");
             }
-            out.println("'>" + g.getDatabaseName() + "</option>");
         }
         out.println("</select>");
     }
index 8b37e90..df78405 100644 (file)
@@ -32,7 +32,7 @@ public class SupportUserDetailsForm extends Form {
 
     private DateSelector dobSelector;
 
-    private GroupSelector value = new GroupSelector("groupToModify");
+    private GroupSelector value = new GroupSelector("groupToModify", true);
 
     public SupportUserDetailsForm(HttpServletRequest hsr, SupportedUser user) {
         super(hsr);