fix: use Group.getByString only when necessary
authorFelix Dörre <felix@dogcraft.de>
Tue, 23 Aug 2016 21:39:52 +0000 (23:39 +0200)
committerFelix Dörre <felix@dogcraft.de>
Tue, 23 Aug 2016 22:42:20 +0000 (00:42 +0200)
Change-Id: I0dd8d6c234cbf62e8a684ab6682003a16a5d017c

src/org/cacert/gigi/pages/LoginPage.java
src/org/cacert/gigi/pages/admin/TTPAdminPage.java
src/org/cacert/gigi/pages/orga/CreateOrgPage.java
src/org/cacert/gigi/pages/wot/RequestTTPForm.java
src/org/cacert/gigi/util/Notary.java
tests/org/cacert/gigi/TestUserGroupMembership.java
tests/org/cacert/gigi/pages/wot/TestTTP.java
tests/org/cacert/gigi/pages/wot/TestTTPAdmin.java

index c206ad444df43c5b0df0a08e4add6612fda6f5c4..1c002e57a00959da796c408c91e0838381448747 100644 (file)
@@ -188,7 +188,7 @@ public class LoginPage extends Page {
         return uc;
     }
 
-    private static final Group LOGIN_BLOCKED = Group.getByString("blockedlogin");
+    private static final Group LOGIN_BLOCKED = Group.BLOCKEDLOGIN;
 
     private void loginSession(HttpServletRequest req, User user) {
         if (user.isInGroup(LOGIN_BLOCKED)) {
index 8d9e47171d8ce7523de2ee84c44e79672c326207..bf773cb4b9ac1946bae5d38b1c319baac3d28bf4 100644 (file)
@@ -22,7 +22,7 @@ public class TTPAdminPage extends Page {
 
     public static final String PATH = "/admin/ttp";
 
-    public static final Group TTP_APPLICANT = Group.getByString("ttp-applicant");
+    public static final Group TTP_APPLICANT = Group.TTP_APPLICANT;
 
     public TTPAdminPage() {
         super("TTP-Admin");
@@ -85,6 +85,6 @@ public class TTPAdminPage extends Page {
 
     @Override
     public boolean isPermitted(AuthorizationContext ac) {
-        return ac != null && ac.isInGroup(Group.getByString("ttp-assurer"));
+        return ac != null && ac.isInGroup(Group.TTP_ASSURER);
     }
 }
index 3219fc019afb11c32ff20ce79d25b0cb6560dc1a..249871f29f31ea57bba7c7f90afcabcdd12e00f4 100644 (file)
@@ -13,7 +13,7 @@ import org.cacert.gigi.util.AuthorizationContext;
 
 public class CreateOrgPage extends Page {
 
-    public static final Group ORG_ASSURER = Group.getByString("orgassurer");
+    public static final Group ORG_ASSURER = Group.ORGASSURER;
 
     public static final String DEFAULT_PATH = "/orga/new";
 
index 85041860526a41ab6c4ac696bcfe02852a16755d..3a6f7fe422c9e2ec885909c317e800e211140484 100644 (file)
@@ -16,7 +16,7 @@ import org.cacert.gigi.pages.LoginPage;
 
 public class RequestTTPForm extends Form {
 
-    public static final Group TTP_APPLICANT = Group.getByString("ttp-applicant");
+    public static final Group TTP_APPLICANT = Group.TTP_APPLICANT;
 
     private static final Template t = new Template(RequestTTPForm.class.getResource("RequestTTPForm.templ"));
 
index 2e6edd66524f4c16e471c163b2ea1b5cc3a7b423..996ddf595110479e54efe71f974a2a12826a8722 100644 (file)
@@ -55,9 +55,9 @@ public class Notary {
         }
     }
 
-    public static final Group ASSURER_BLOCKED = Group.getByString("blockedassurer");
+    public static final Group ASSURER_BLOCKED = Group.BLOCKEDASSURER;
 
-    public static final Group ASSUREE_BLOCKED = Group.getByString("blockedassuree");
+    public static final Group ASSUREE_BLOCKED = Group.BLOCKEDASSUREE;
 
     /**
      * This method assures another user.
index ea92218b2ecdc4f25273bfa9a39c3567270cdcde..bd1fd4f79d943075666944064f943827ec7ee67b 100644 (file)
@@ -19,9 +19,9 @@ import org.junit.Test;
 
 public class TestUserGroupMembership extends BusinessTest {
 
-    private final Group ttpGroup = Group.getByString("ttp-assurer");
+    private final Group ttpGroup = Group.TTP_ASSURER;
 
-    private final Group supporter = Group.getByString("supporter");
+    private final Group supporter = Group.SUPPORTER;
 
     @Test
     public void testAddObject() throws GigiApiException, SQLException, IOException {
index 0d3763868fd25b15383ef4fa833394b4e2c2b8d5..560d1b5653559b183bbf34da63fc0013477937bf 100644 (file)
@@ -27,7 +27,7 @@ public class TestTTP extends ClientTest {
         assertThat(ttp, not(containsString("<form")));
         ObjectCache.clearAllCaches();
         u = User.getById(u.getId());
-        assertTrue(u.isInGroup(Group.getByString("ttp-applicant")));
+        assertTrue(u.isInGroup(Group.TTP_APPLICANT));
     }
 
     @Test
index d04b0b66cd921f22cef3649fc9cee94045400c5b..12430b7c84ea36e4c3e6b06d8244230e7328c80a 100644 (file)
@@ -32,7 +32,7 @@ public class TestTTPAdmin extends ClientTest {
 
     public void testTTPAdmin(boolean hasRight) throws IOException, GigiApiException {
         if (hasRight) {
-            grant(u, Group.getByString("ttp-assurer"));
+            grant(u, Group.TTP_ASSURER);
         }
         grant(u, TTPAdminPage.TTP_APPLICANT);
         cookie = login(u.getEmail(), TEST_PASSWORD);