+ }
+
+ public static void may(User assurer, User assuree, AssuranceType t) throws GigiApiException {
+ if (assuree.isInGroup(ASSUREE_BLOCKED)) {
+ throw new GigiApiException("The applicant is blocked.");
+ }
+ if (assurer.isInGroup(ASSURER_BLOCKED)) {
+ throw new GigiApiException("The RA Agent is blocked.");
+ }
+
+ if (t == AssuranceType.NUCLEUS) {
+ if ( !assurer.isInGroup(Group.NUCLEUS_ASSURER)) {
+ throw new GigiApiException("RA Agent needs to be Nucleus RA Agent.");
+ }
+ return;
+ } else if (t == AssuranceType.TTP_ASSISTED) {
+ if ( !assurer.isInGroup(Group.TTP_ASSURER)) {
+ throw new GigiApiException("RA Agent needs to be TTP RA Agent.");
+ }
+ if ( !assuree.isInGroup(Group.TTP_APPLICANT)) {
+ throw new GigiApiException("Applicant needs to be TTP Applicant.");
+ }
+ return;
+ } else if (t == AssuranceType.FACE_TO_FACE) {
+ return;
+ }
+ throw new GigiApiException("Verification type not possible.");
+ }
+
+ private static void assureNucleus(User assurer, User assuree, Name name, int awarded, String location, String date) throws GigiApiException {
+ may(assurer, assuree, AssuranceType.NUCLEUS);
+ // Do up to 35 points as f2f
+ int f2fPoints = Math.min(assurer.getMaxAssurePoints(), awarded);
+ assureF2F(assurer, assuree, name, 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, name.getId());
+ ps.setInt(3, awarded);
+ ps.setString(4, location);
+ ps.setString(5, date);
+ ps.execute();