]> WPIA git - gigi.git/commitdiff
add: nucleus assurance
authorFelix Dörre <felix@dogcraft.de>
Thu, 7 Apr 2016 11:36:17 +0000 (13:36 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 7 Apr 2016 11:58:24 +0000 (13:58 +0200)
src/org/cacert/gigi/database/DatabaseConnection.java
src/org/cacert/gigi/database/tableStructure.sql
src/org/cacert/gigi/database/upgrade/from_8.sql [new file with mode: 0644]
src/org/cacert/gigi/dbObjects/Assurance.java
src/org/cacert/gigi/dbObjects/Group.java
src/org/cacert/gigi/util/Notary.java
util-testing/org/cacert/gigi/pages/Manager.templ

index 525ce44f8f9de11cfd7aed67d349b09a87c71ce2..bf7cd3be38bea730e76b90cf1e5accf1c577929b 100644 (file)
@@ -99,7 +99,7 @@ public class DatabaseConnection {
 
     }
 
-    public static final int CURRENT_SCHEMA_VERSION = 8;
+    public static final int CURRENT_SCHEMA_VERSION = 9;
 
     public static final int CONNECTION_TIMEOUT = 24 * 60 * 60;
 
index a6aaf385a0ba49107356bc469f617a2fe66bd184..e49b84af15a29a587e2733eedeba3c18ab33afe6 100644 (file)
@@ -262,7 +262,7 @@ CREATE INDEX ON "jobs" ("state");
 DROP TABLE IF EXISTS "notary";
 
 DROP TYPE IF EXISTS "notaryType";
-CREATE TYPE "notaryType" AS enum('Face to Face Meeting', 'TOPUP', 'TTP-Assisted');
+CREATE TYPE "notaryType" AS enum('Face to Face Meeting', 'TOPUP', 'TTP-Assisted', 'Nucleus Bonus');
 
 CREATE TABLE "notary" (
   "id" serial NOT NULL,
@@ -327,7 +327,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');
+CREATE TYPE "userGroup" AS enum('supporter','arbitrator','blockedassuree','blockedassurer','blockedlogin','ttp-assurer','ttp-applicant', 'codesigning', 'orgassurer', 'blockedcert', 'nucleus-assurer');
 
 CREATE TABLE IF NOT EXISTS "user_groups" (
   "id" serial NOT NULL,
@@ -374,7 +374,7 @@ CREATE TABLE "schemeVersion" (
   "version" smallint NOT NULL,
   PRIMARY KEY ("version")
 );
-INSERT INTO "schemeVersion" (version)  VALUES(8);
+INSERT INTO "schemeVersion" (version)  VALUES(9);
 
 DROP TABLE IF EXISTS `passwordResetTickets`;
 CREATE TABLE `passwordResetTickets` (
diff --git a/src/org/cacert/gigi/database/upgrade/from_8.sql b/src/org/cacert/gigi/database/upgrade/from_8.sql
new file mode 100644 (file)
index 0000000..7e20cf3
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TYPE "notaryType" ADD VALUE 'Nucleus Bonus';
+
+ALTER TYPE "userGroup" ADD VALUE  'nucleus-assurer';
index 8f172e51a62f98aafd0d381fcc2b3b6400b3544c..65a5a59945e98deb1a0f42a57bf322540eb6825d 100644 (file)
@@ -6,7 +6,7 @@ import org.cacert.gigi.dbObjects.wrappers.DataContainer;
 public class Assurance {
 
     public enum AssuranceType {
-        FACE_TO_FACE("Face to Face Meeting"), TOPUP("TOPUP"), TTP_ASSISTED("TTP-Assisted");
+        FACE_TO_FACE("Face to Face Meeting"), TOPUP("TOPUP"), TTP_ASSISTED("TTP-Assisted"), NUCLEUS("Nucleus Bonus");
 
         private final String description;
 
index 685c27e1f10fdda1ed57618e2659f9d8462ee9f0..296b4dfa2536639169337d622f81e81b7d71ae72 100644 (file)
@@ -4,7 +4,7 @@ import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.database.GigiResultSet;
 
 public enum Group {
-    SUPPORTER("supporter"), ARBITRATOR("arbitrator"), BLOCKEDASSURER("blockedassurer"), BLOCKEDASSUREE("blockedassuree"), BLOCKEDLOGIN("blockedlogin"), BLOCKEDCERT("blockedcert"), TTP_ASSURER("ttp-assurer"), TTP_APPLICANT("ttp-applicant"), CODESIGNING("codesigning"), ORGASSURER("orgassurer");
+    SUPPORTER("supporter"), ARBITRATOR("arbitrator"), BLOCKEDASSURER("blockedassurer"), BLOCKEDASSUREE("blockedassuree"), BLOCKEDLOGIN("blockedlogin"), BLOCKEDCERT("blockedcert"), TTP_ASSURER("ttp-assurer"), TTP_APPLICANT("ttp-applicant"), CODESIGNING("codesigning"), ORGASSURER("orgassurer"), NUCLEUS_ASSURER("nucleus-assurer");
 
     private final String dbName;
 
index 2f3a3aec56764dc520898aeea1b292ba91cf3b95..aa806fa929ce2b06ee4d4f31c5ce837213cddeae 100644 (file)
@@ -129,6 +129,8 @@ public class Notary {
 
         if (type == AssuranceType.FACE_TO_FACE) {
             assureF2F(assurer, assuree, awarded, location, date);
+        } else if (type == AssuranceType.NUCLEUS) {
+            assureNucleus(assurer, assuree, awarded, location, date);
         } else if (type == AssuranceType.TTP_ASSISTED) {
             assureTTP(assurer, assuree, awarded, location, date);
         } else {
@@ -189,4 +191,27 @@ public class Notary {
         }
         throw new GigiApiException("Assurance type not possible.");
     }
+
+    private static void assureNucleus(User assurer, User assuree, int awarded, String location, String date) throws GigiApiException {
+        may(assurer, assuree, AssuranceType.NUCLEUS);
+        // Do up to 35 points as f2f
+        int f2fPoints = Math.min(35, awarded);
+        assureF2F(assurer, assuree, f2fPoints, location, date);
+
+        awarded -= f2fPoints;
+        if (awarded <= 0) {
+            return;
+        }
+
+        // Assure remaining points as "Nucleus Bonus"
+        // Valid for 4 Weeks = 28 days
+        try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `method`='Nucleus Bonus', `expire` = CURRENT_TIMESTAMP + interval '28 days'")) {
+            ps.setInt(1, assurer.getId());
+            ps.setInt(2, assuree.getId());
+            ps.setInt(3, awarded);
+            ps.setString(4, location);
+            ps.setString(5, date);
+            ps.execute();
+        }
+    }
 }
index 434ccf97c3f4cd946b99b85e209726eaa599681d..9735e9a53ea4eaebe5b4f172b9076bdf21152ee4 100644 (file)
@@ -24,6 +24,7 @@ Email: <input type="text" name="email"/>
 <option>blockedlogin</option>
 <option>ttp-assurer</option>
 <option>ttp-applicant</option>
+<option>nucleus-assurer</option>
 <option>codesigning</option>
 <option>orgassurer</option>
 </select>