+ }
+
+ private static void assureTTP(User assurer, User assuree, int awarded, String location, String date) throws GigiApiException {
+ may(assurer, assuree, AssuranceType.TTP_ASSISTED);
+ try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `method`='TTP-Assisted'")) {
+ ps.setInt(1, assurer.getId());
+ ps.setInt(2, assuree.getId());
+ ps.setInt(3, awarded);
+ ps.setString(4, location);
+ ps.setString(5, date);
+ ps.execute();
+ assuree.revokeGroup(assurer, Group.TTP_APPLICANT);
+ }
+ }
+
+ public static void may(User assurer, User assuree, AssuranceType t) throws GigiApiException {
+ if (assuree.isInGroup(ASSUREE_BLOCKED)) {
+ throw new GigiApiException("The assuree is blocked.");
+ }
+ if (assurer.isInGroup(ASSURER_BLOCKED)) {
+ throw new GigiApiException("The assurer is blocked.");
+ }
+
+ if (t == AssuranceType.NUCLEUS) {
+ if ( !assurer.isInGroup(Group.NUCLEUS_ASSURER)) {
+ throw new GigiApiException("Assurer needs to be Nucleus Assurer.");
+ }
+ return;
+ } else if (t == AssuranceType.TTP_ASSISTED) {
+ if ( !assurer.isInGroup(Group.TTP_ASSURER)) {
+ throw new GigiApiException("Assurer needs to be TTP Assurer.");
+ }
+ if ( !assuree.isInGroup(Group.TTP_APPLICANT)) {
+ throw new GigiApiException("Assuree needs to be TTP Applicant.");
+ }
+ return;
+ } else if (t == AssuranceType.FACE_TO_FACE) {
+ return;
+ }
+ throw new GigiApiException("Assurance type not possible.");