]> WPIA git - gigi.git/commitdiff
Merge "upd: terminology in API"
authorBenny Baumann <BenBE1987@gmx.net>
Mon, 27 Feb 2017 19:31:01 +0000 (20:31 +0100)
committerGerrit Code Review <gigi-system@dogcraft.de>
Mon, 27 Feb 2017 19:31:01 +0000 (20:31 +0100)
18 files changed:
src/club/wpia/gigi/database/DatabaseConnection.java
src/club/wpia/gigi/database/tableStructure.sql
src/club/wpia/gigi/database/upgrade/from_26.sql [new file with mode: 0644]
src/club/wpia/gigi/dbObjects/Group.java
src/club/wpia/gigi/dbObjects/Organisation.java
src/club/wpia/gigi/pages/LoginPage.java
src/club/wpia/gigi/pages/account/certs/CertificateAdd.java
src/club/wpia/gigi/pages/admin/TTPAdminPage.java
src/club/wpia/gigi/pages/orga/CreateOrgPage.java
src/club/wpia/gigi/util/Notary.java
tests/club/wpia/gigi/TestOrga.java
tests/club/wpia/gigi/TestUserGroupMembership.java
tests/club/wpia/gigi/api/IssueCert.java
tests/club/wpia/gigi/pages/wot/TestTTPAdmin.java
tests/club/wpia/gigi/testUtils/OrgTest.java
tests/club/wpia/gigi/testUtils/RestrictedApiTest.java
tests/club/wpia/gigi/util/TestNotary.java
util-testing/club/wpia/gigi/pages/Manager.templ

index 0d595707fee890f628471f7e168dc72e57169fbd..26449809e37bab02927af5acb4255235e7e256a2 100644 (file)
@@ -122,7 +122,7 @@ public class DatabaseConnection {
 
     }
 
-    public static final int CURRENT_SCHEMA_VERSION = 26;
+    public static final int CURRENT_SCHEMA_VERSION = 27;
 
     public static final int CONNECTION_TIMEOUT = 24 * 60 * 60;
 
index 304d85d995b3f71cf5959b1a74c3a5e452389859..57825338bdf2180fd67ec1d0a287f1c42b2e076f 100644 (file)
@@ -328,7 +328,7 @@ CREATE TABLE IF NOT EXISTS "arbitrations" (
 DROP TABLE IF EXISTS "user_groups";
 
 DROP TYPE IF EXISTS "userGroup";
-CREATE TYPE "userGroup" AS enum('supporter','arbitrator','blockedassuree','blockedassurer','blockedlogin','ttp-assurer','ttp-applicant', 'codesigning', 'orgassurer', 'blockedcert', 'nucleus-assurer', 'locate-agent', 'verify-notification');
+CREATE TYPE "userGroup" AS enum('supporter','blocked-applicant','blocked-agent','blocked-login','ttp-agent','ttp-applicant', 'codesigning', 'org-agent', 'blocked-cert', 'nucleus-agent', 'locate-agent', 'verify-notification');
 
 CREATE TABLE IF NOT EXISTS "user_groups" (
   "id" serial NOT NULL,
@@ -375,7 +375,7 @@ CREATE TABLE "schemeVersion" (
   "version" smallint NOT NULL,
   PRIMARY KEY ("version")
 );
-INSERT INTO "schemeVersion" (version)  VALUES(26);
+INSERT INTO "schemeVersion" (version)  VALUES(27);
 
 DROP TABLE IF EXISTS `passwordResetTickets`;
 CREATE TABLE `passwordResetTickets` (
diff --git a/src/club/wpia/gigi/database/upgrade/from_26.sql b/src/club/wpia/gigi/database/upgrade/from_26.sql
new file mode 100644 (file)
index 0000000..9844501
--- /dev/null
@@ -0,0 +1,15 @@
+DELETE FROM "user_groups" WHERE "permission" = 'arbitrator'::"userGroup";
+
+ALTER TYPE "userGroup" RENAME TO "oldUserGroup";
+CREATE TYPE "userGroup" AS enum('supporter','blocked-agent','blocked-applicant','blocked-login','ttp-agent','ttp-applicant', 'codesigning', 'org-agent', 'blocked-cert', 'nucleus-agent', 'locate-agent', 'verify-notification');
+ALTER TABLE "user_groups" ALTER COLUMN "permission" SET DATA TYPE "userGroup" USING
+    CASE "permission" WHEN 'blockedassurer' THEN 'blocked-agent'::"userGroup"
+                      WHEN 'blockedassuree' THEN 'blocked-applicant'::"userGroup"
+                      WHEN 'ttp-assurer' THEN 'ttp-agent'::"userGroup"
+                      WHEN 'orgassurer' THEN 'org-agent'::"userGroup"
+                      WHEN 'nucleus-assurer' THEN 'nucleus-agent'::"userGroup"
+                      WHEN 'blockedcert' THEN 'blocked-cert'::"userGroup"
+                      WHEN 'blockedlogin' THEN 'blocked-login'::"userGroup"
+                      ELSE "permission"::text::"userGroup"
+    END;
+DROP TYPE "oldUserGroup";
index 1acc461b3e915d2b85cb6e786486396aa5ad6578..778c46e014d1da29f246b9f57e831071b7255705 100644 (file)
@@ -8,16 +8,15 @@ import club.wpia.gigi.output.template.TranslateCommand;
 
 public enum Group implements DBEnum {
     SUPPORTER("supporter", "supporter", true, false, true), //
-    ARBITRATOR("arbitrator", "arbitrator", true, false, true), //
-    BLOCKEDASSURER("blockedassurer", "may not verify", true, false, false), //
-    BLOCKEDASSUREE("blockedassuree", "may not be verified", true, false, false), //
-    BLOCKEDLOGIN("blockedlogin", "may not login", true, false, false), //
-    BLOCKEDCERT("blockedcert", "may not issue certificates", true, false, false), //
-    TTP_ASSURER("ttp-assurer", "may verify via TTP", true, false, true), //
+    BLOCKED_AGENT("blocked-agent", "may not verify", true, false, false), //
+    BLOCKED_APPLICANT("blocked-applicant", "may not be verified", true, false, false), //
+    BLOCKED_LOGIN("blocked-login", "may not login", true, false, false), //
+    BLOCKED_CERT("blocked-cert", "may not issue certificates", true, false, false), //
+    TTP_AGENT("ttp-agent", "may verify via TTP", true, false, true), //
     TTP_APPLICANT("ttp-applicant", "requests to be verified via ttp", false, true, false), //
     CODESIGNING("codesigning", "may issue codesigning certificates", true, false, false), //
-    ORGASSURER("orgassurer", "may verify organisations", true, false, true), //
-    NUCLEUS_ASSURER("nucleus-assurer", "may enter nucleus verifications", true, false, true), //
+    ORG_AGENT("org-agent", "may verify organisations", true, false, true), //
+    NUCLEUS_AGENT("nucleus-agent", "may enter nucleus verifications", true, false, true), //
     LOCATE_AGENT("locate-agent", "wants access to the locate agent system", false, true, false), //
     VERIFY_NOTIFICATION("verify-notification", "wants to receive an email notification for any Verification they enter", false, true, false);
 
index 1e8a38d46f1382df9525405c37995f1d9e5a50dc..c47a7837ba3cbda87d7cb83390bd2d73194faf92 100644 (file)
@@ -67,7 +67,7 @@ public class Organisation extends CertificateOwner {
     private String postalAddress;
 
     public Organisation(String name, Country country, String province, String city, String email, String optionalName, String postalAddress, User creator) throws GigiApiException {
-        if ( !creator.isInGroup(Group.ORGASSURER)) {
+        if ( !creator.isInGroup(Group.ORG_AGENT)) {
             throw new GigiApiException("Only Organisation RA Agents may create organisations.");
         }
         if (country == null) {
@@ -148,7 +148,7 @@ public class Organisation extends CertificateOwner {
         if ( !admin.canVerify()) {
             throw new GigiApiException("Cannot add person who is not RA Agent.");
         }
-        if ( !actor.isInGroup(Group.ORGASSURER) && !isMaster(actor)) {
+        if ( !actor.isInGroup(Group.ORG_AGENT) && !isMaster(actor)) {
             throw new GigiApiException("Only Organisation RA Agents or Organisation Administrators may add admins to an organisation.");
         }
         try (GigiPreparedStatement ps1 = new GigiPreparedStatement("SELECT 1 FROM `org_admin` WHERE `orgid`=? AND `memid`=? AND `deleted` IS NULL")) {
@@ -169,7 +169,7 @@ public class Organisation extends CertificateOwner {
     }
 
     public void removeAdmin(User admin, User actor) throws GigiApiException {
-        if ( !actor.isInGroup(Group.ORGASSURER) && !isMaster(actor)) {
+        if ( !actor.isInGroup(Group.ORG_AGENT) && !isMaster(actor)) {
             throw new GigiApiException("Only Organisation RA Agents or Organisation Administrators may delete admins from an organisation.");
         }
         try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE org_admin SET deleter=?, deleted=NOW() WHERE orgid=? AND memid=?")) {
index f4418891d16a9facd6a343772dfe958fe73773cc..69b93863366d5b1928cee228812756e169478022 100644 (file)
@@ -188,7 +188,7 @@ public class LoginPage extends Page {
         return uc;
     }
 
-    private static final Group LOGIN_BLOCKED = Group.BLOCKEDLOGIN;
+    private static final Group LOGIN_BLOCKED = Group.BLOCKED_LOGIN;
 
     private void loginSession(HttpServletRequest req, User user) {
         if (user.isInGroup(LOGIN_BLOCKED)) {
index d628c588833e75a0c3311859d0d6935e8ec390a4..c04dcb3bf49389aa6db9af9fc9349fac115ce8d6 100644 (file)
@@ -24,6 +24,6 @@ public class CertificateAdd extends ManagedFormPage {
 
     @Override
     public boolean isPermitted(AuthorizationContext ac) {
-        return super.isPermitted(ac) && !ac.isInGroup(Group.BLOCKEDCERT);
+        return super.isPermitted(ac) && !ac.isInGroup(Group.BLOCKED_CERT);
     }
 }
index d3c1c5906428bac49ab0493f0c6eec3010530aed..3e7c4e86e52baa2b38d6fb2e5b20c5c8616c2d6b 100644 (file)
@@ -90,6 +90,6 @@ public class TTPAdminPage extends Page {
 
     @Override
     public boolean isPermitted(AuthorizationContext ac) {
-        return ac != null && ac.isInGroup(Group.TTP_ASSURER);
+        return ac != null && ac.isInGroup(Group.TTP_AGENT);
     }
 }
index a4f129a2eed512d871051141514cd17ba6efce10..4eab3d6e274dcb79ba319e14fd2f9cea07a86eda 100644 (file)
@@ -12,7 +12,7 @@ import club.wpia.gigi.util.AuthorizationContext;
 
 public class CreateOrgPage extends ManagedFormPage {
 
-    public static final Group ORG_AGENT = Group.ORGASSURER;
+    public static final Group ORG_AGENT = Group.ORG_AGENT;
 
     public static final String DEFAULT_PATH = "/orga/new";
 
index a619da53563e3b60f5d0849458ddf17f50b26b0a..da80752259cbf9c6edf01043ccefaa4c97b04129 100644 (file)
@@ -55,9 +55,9 @@ public class Notary {
         }
     }
 
-    public static final Group AGENT_BLOCKED = Group.BLOCKEDASSURER;
+    public static final Group AGENT_BLOCKED = Group.BLOCKED_AGENT;
 
-    public static final Group APPLICANT_BLOCKED = Group.BLOCKEDASSUREE;
+    public static final Group APPLICANT_BLOCKED = Group.BLOCKED_APPLICANT;
 
     public static final Group VERIFY_NOTIFICATION = Group.VERIFY_NOTIFICATION;
 
@@ -207,12 +207,12 @@ public class Notary {
         }
 
         if (t == VerificationType.NUCLEUS) {
-            if ( !agent.isInGroup(Group.NUCLEUS_ASSURER)) {
+            if ( !agent.isInGroup(Group.NUCLEUS_AGENT)) {
                 throw new GigiApiException("RA Agent needs to be Nucleus RA Agent.");
             }
             return;
         } else if (t == VerificationType.TTP_ASSISTED) {
-            if ( !agent.isInGroup(Group.TTP_ASSURER)) {
+            if ( !agent.isInGroup(Group.TTP_AGENT)) {
                 throw new GigiApiException("RA Agent needs to be TTP RA Agent.");
             }
             if ( !applicant.isInGroup(Group.TTP_APPLICANT)) {
index 2c08c309807ff22d79ca4efdd0fe94c1b9eb4cc4..73b294f3e83203ea99b1eafd94e0062755c2ae9e 100644 (file)
@@ -18,13 +18,13 @@ public class TestOrga extends BusinessTest {
     @Test
     public void testAddRm() throws GigiApiException, IOException {
         User u1 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD));
-        u1.grantGroup(getSupporter(), Group.ORGASSURER);
+        u1.grantGroup(getSupporter(), Group.ORG_AGENT);
         User u2 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD));
-        u2.grantGroup(getSupporter(), Group.ORGASSURER);
+        u2.grantGroup(getSupporter(), Group.ORG_AGENT);
         User u3 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD));
-        u3.grantGroup(getSupporter(), Group.ORGASSURER);
+        u3.grantGroup(getSupporter(), Group.ORG_AGENT);
         User u4 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD));
-        u4.grantGroup(getSupporter(), Group.ORGASSURER);
+        u4.grantGroup(getSupporter(), Group.ORG_AGENT);
         Organisation o1 = new Organisation("name", Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS), "prov", "city", "email", "optional name", "postal address", u1);
         assertEquals(0, o1.getAllAdmins().size());
         o1.addAdmin(u2, u1, false);
index d0e7a2bf0dafdf2d4762a9b8cf8696a0fab3bab7..4ecd38f5dc115d1af55fe523b47ce56d7f2168fd 100644 (file)
@@ -20,7 +20,7 @@ import club.wpia.gigi.testUtils.BusinessTest;
 
 public class TestUserGroupMembership extends BusinessTest {
 
-    private final Group ttpGroup = Group.TTP_ASSURER;
+    private final Group ttpGroup = Group.TTP_AGENT;
 
     private final Group supporter = Group.SUPPORTER;
 
index 757e50a77a28f6295ca91413cfb6e753c59d489d..5c4791e5788c0f76b6ffe77d88608e9ffd1a3840 100644 (file)
@@ -88,7 +88,7 @@ public class IssueCert extends ClientTest {
     @Test
     public void testIssueOrgCert() throws Exception {
         makeAgent(id);
-        u.grantGroup(getSupporter(), Group.ORGASSURER);
+        u.grantGroup(getSupporter(), Group.ORG_AGENT);
 
         Organisation o1 = new Organisation("name", Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS), "pr", "st", "test@mail", "", "", u);
         o1.addAdmin(u, u, false);
index 2e3c386284d776c8b8b3d6a37919aa0fbd7b2778..d518dea4e3c177986222730576e1e357c2872b57 100644 (file)
@@ -33,7 +33,7 @@ public class TestTTPAdmin extends ClientTest {
 
     public void testTTPAdmin(boolean hasRight) throws IOException, GigiApiException {
         if (hasRight) {
-            grant(u, Group.TTP_ASSURER);
+            grant(u, Group.TTP_AGENT);
         }
         grant(u, TTPAdminPage.TTP_APPLICANT);
         cookie = login(u.getEmail(), TEST_PASSWORD);
index 949bd2d1ebc8cc98c1754d91b80a45a9bcbf43a4..6a0c4d1c68cf70330b6ae4404656e6fe6e5d7b6f 100644 (file)
@@ -12,7 +12,7 @@ public class OrgTest extends ClientTest {
 
     public OrgTest() throws IOException, GigiApiException {
         makeAgent(u.getId());
-        u.grantGroup(getSupporter(), Group.ORGASSURER);
+        u.grantGroup(getSupporter(), Group.ORG_AGENT);
         clearCaches();
         cookie = login(email, TEST_PASSWORD);
     }
index 3a0f45157cb3e501bb48bec0e6973850a6a9705e..37adb6beb4fc9c6cac4e1160d1f8eac8ed4aa704 100644 (file)
@@ -43,7 +43,7 @@ public class RestrictedApiTest extends ClientTest {
         initEnvironment();
         try {
             User u = User.getById(createVerificationUser("f", "l", createUniqueName() + "@email.com", TEST_PASSWORD));
-            grant(u, Group.ORGASSURER);
+            grant(u, Group.ORG_AGENT);
             clearCaches();
             u = User.getById(u.getId());
             selfOrg = new Organisation(Organisation.SELF_ORG_NAME, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS), "NA", "NA", "contact@example.org", "", "", u);
index 45217fd8d00fc8d3afd0656a7d257152023c883f..4028ebdaea80451673e7b7f8ca732048c16462be 100644 (file)
@@ -135,7 +135,7 @@ public class TestNotary extends BusinessTest {
     @Test
     public void testNucleus() throws SQLException, GigiApiException, IOException {
         User agent = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
-        agent.grantGroup(getSupporter(), Group.NUCLEUS_ASSURER);
+        agent.grantGroup(getSupporter(), Group.NUCLEUS_AGENT);
         User applicant = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
         Name n1 = applicant.getPreferredName();
         Name n2 = new Name(applicant, new NamePart(NamePartType.FIRST_NAME, "F2"), new NamePart(NamePartType.LAST_NAME, "L2"));
@@ -157,9 +157,9 @@ public class TestNotary extends BusinessTest {
     @Test
     public void testNucleusProcess() throws SQLException, GigiApiException, IOException {
         User agent1 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
-        agent1.grantGroup(getSupporter(), Group.NUCLEUS_ASSURER);
+        agent1.grantGroup(getSupporter(), Group.NUCLEUS_AGENT);
         User agent2 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
-        agent2.grantGroup(getSupporter(), Group.NUCLEUS_ASSURER);
+        agent2.grantGroup(getSupporter(), Group.NUCLEUS_AGENT);
         User applicant = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD));
         Notary.verify(agent1, applicant, applicant.getPreferredName(), applicant.getDoB(), 50, "test", validVerificationDateString(), VerificationType.NUCLEUS, DE);
         Notary.verify(agent2, applicant, applicant.getPreferredName(), applicant.getDoB(), 50, "test", validVerificationDateString(), VerificationType.NUCLEUS, DE);
index 7cef16083e47f69c90ba76645deefd887ad247fb..e63552d455f1b1c64ae23615ea770e5bbf8e180d 100644 (file)
@@ -18,15 +18,14 @@ Email: <input type="text" name="email"/>
 </td><td>
 <select name="priv">
 <option>supporter</option>
-<option>arbitrator</option>
-<option>blockedassuree</option>
-<option>blockedassurer</option>
-<option>blockedlogin</option>
-<option>ttp-assurer</option>
+<option>blocked-applicant</option>
+<option>blocked-agent</option>
+<option>blocked-login</option>
+<option>ttp-agent</option>
 <option>ttp-applicant</option>
-<option>nucleus-assurer</option>
+<option>nucleus-agent</option>
 <option>codesigning</option>
-<option>orgassurer</option>
+<option>org-agent</option>
 </select>
 <input type="submit" name="addpriv" value="Grant Privillege"/>
 <input type="submit" name="delpriv" value="Revoke Privillege"/>