1 package org.cacert.gigi.dbObjects;
3 import org.cacert.gigi.database.GigiPreparedStatement;
4 import org.cacert.gigi.database.GigiResultSet;
5 import org.cacert.gigi.output.template.Outputable;
6 import org.cacert.gigi.output.template.TranslateCommand;
9 SUPPORTER("supporter", "supporter", true), ARBITRATOR("arbitrator", "arbitrator", true), //
10 BLOCKEDASSURER("blockedassurer", "may not verify", true), BLOCKEDASSUREE("blockedassuree", "may not be verified", true), //
11 BLOCKEDLOGIN("blockedlogin", "may not login", true), BLOCKEDCERT("blockedcert", "may not issue certificates", true), //
12 TTP_ASSURER("ttp-assurer", "may verify via TTP", true), TTP_APPLICANT("ttp-applicant", "requests to be verified via ttp", true), //
13 CODESIGNING("codesigning", "may issue codesigning certificates", true), ORGASSURER("orgassurer", "may verify organisations", true), //
14 NUCLEUS_ASSURER("nucleus-assurer", "may enter nucleus verifications", true), LOCATE_AGENT("locate-agent", "wants access to the locate agent system", false);
16 private final String dbName;
18 private final TranslateCommand tc;
20 private final boolean managedBySupport; // true if flag is handled by
21 // support, false if handled by user
23 private Group(String name, String display, boolean managedBySupport) {
25 tc = new TranslateCommand(display);
26 this.managedBySupport = managedBySupport;
29 public static Group getByString(String name) {
30 return valueOf(name.toUpperCase().replace('-', '_'));
33 public boolean isManagedBySupport() {
34 return managedBySupport;
37 public String getDatabaseName() {
41 public User[] getMembers(int offset, int count) {
42 try (GigiPreparedStatement gps = new GigiPreparedStatement("SELECT `user` FROM `user_groups` WHERE `permission`=?::`userGroup` AND `deleted` IS NULL OFFSET ? LIMIT ?", true)) {
43 gps.setString(1, dbName);
44 gps.setInt(2, offset);
46 GigiResultSet grs = gps.executeQuery();
48 User[] users = new User[grs.getRow()];
52 users[i++] = User.getById(grs.getInt(1));
58 public Outputable getName() {