}
- 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;
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,
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,
"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` (
--- /dev/null
+ALTER TYPE "notaryType" ADD VALUE 'Nucleus Bonus';
+
+ALTER TYPE "userGroup" ADD VALUE 'nucleus-assurer';
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;
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;
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 {
}
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();
+ }
+ }
}
<option>blockedlogin</option>
<option>ttp-assurer</option>
<option>ttp-applicant</option>
+<option>nucleus-assurer</option>
<option>codesigning</option>
<option>orgassurer</option>
</select>