+ if ( !checkAssuranceIsPossible(assurer, assureeName)) {
+ gae.mergeInto(new GigiApiException(SprintfCommand.createSimple("You have already verified this applicant within the last {0} days.", LIMIT_DAYS_VERIFICATION)));
+ }
+
+ if ( !assuree.getDoB().equals(dob)) {
+ gae.mergeInto(new GigiApiException("The person you are verifying changed his personal details."));
+ }
+
+ if (awarded < 0) {
+ gae.mergeInto(new GigiApiException("The points you are trying to award are out of range."));
+ } else {
+ if (type == AssuranceType.NUCLEUS) {
+ if (awarded > 50) {
+ gae.mergeInto(new GigiApiException("The points you are trying to award are out of range."));
+ }
+ } else {
+ if (awarded > assurer.getMaxAssurePoints()) {
+ gae.mergeInto(new GigiApiException("The points you are trying to award are out of range."));
+ }
+ }
+ }
+
+ if ( !gae.isEmpty()) {
+ throw gae;
+ }
+
+ if (type == AssuranceType.FACE_TO_FACE) {
+ assureF2F(assurer, assuree, assureeName, awarded, location, date);
+ } else if (type == AssuranceType.NUCLEUS) {
+ assureNucleus(assurer, assuree, assureeName, awarded, location, date);
+ } else if (type == AssuranceType.TTP_ASSISTED) {
+ assureTTP(assurer, assuree, assureeName, awarded, location, date);
+ } else {
+ throw new GigiApiException(SprintfCommand.createSimple("Unknown Assurance type: {0}", type.toString()));
+ }
+ assurer.invalidateMadeAssurances();
+ assuree.invalidateReceivedAssurances();
+ }
+ }
+
+ private static void assureF2F(User assurer, User assuree, Name name, int awarded, String location, String date) throws GigiApiException {
+ may(assurer, assuree, AssuranceType.FACE_TO_FACE);
+ try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?")) {
+ ps.setInt(1, assurer.getId());
+ ps.setInt(2, name.getId());
+ ps.setInt(3, awarded);
+ ps.setString(4, location);
+ ps.setString(5, date);
+ ps.execute();
+ }
+ }
+
+ private static void assureTTP(User assurer, User assuree, Name name, 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, name.getId());
+ ps.setInt(3, awarded);
+ ps.setString(4, location);
+ ps.setString(5, date);
+ ps.execute();
+ assuree.revokeGroup(assurer, Group.TTP_APPLICANT);