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"), ARBITRATOR("arbitrator", "arbitrator"), //
10 BLOCKEDASSURER("blockedassurer", "may not verify"), BLOCKEDASSUREE("blockedassuree", "may not be verified"), //
11 BLOCKEDLOGIN("blockedlogin", "may not login"), BLOCKEDCERT("blockedcert", "may not issue certificates"), //
12 TTP_ASSURER("ttp-assurer", "may verify via TTP"), TTP_APPLICANT("ttp-applicant", "requests to be verified via ttp"), //
13 CODESIGNING("codesigning", "may issue codesigning certificates"), ORGASSURER("orgassurer", "may verify organisations"), //
14 NUCLEUS_ASSURER("nucleus-assurer", "may enter nucleus verifications"), LOCATE_AGENT("locate-agent", "wants access to the locate agent system");
16 private final String dbName;
18 private final TranslateCommand tc;
20 private Group(String name, String display) {
22 tc = new TranslateCommand(display);
25 public static Group getByString(String name) {
26 return valueOf(name.toUpperCase().replace('-', '_'));
29 public String getDatabaseName() {
33 public User[] getMembers(int offset, int count) {
34 try (GigiPreparedStatement gps = new GigiPreparedStatement("SELECT `user` FROM `user_groups` WHERE `permission`=?::`userGroup` AND `deleted` IS NULL OFFSET ? LIMIT ?", true)) {
35 gps.setString(1, dbName);
36 gps.setInt(2, offset);
38 GigiResultSet grs = gps.executeQuery();
40 User[] users = new User[grs.getRow()];
44 users[i++] = User.getById(grs.getInt(1));
50 public Outputable getName() {