]> WPIA git - gigi.git/blobdiff - src/club/wpia/gigi/util/Notary.java
add: ensure that for TTPAgent action there is a valid TTPAgent Challenge
[gigi.git] / src / club / wpia / gigi / util / Notary.java
index 36f1fa48c3c603c3c1dd5ed7ab3a30437bf5d2a1..a345f57e898b077b43b266608691620c74a5ff6c 100644 (file)
@@ -3,7 +3,6 @@ package club.wpia.gigi.util;
 import java.io.IOException;
 import java.text.ParseException;
 import java.util.Calendar;
-import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.Map;
@@ -93,13 +92,11 @@ public class Notary {
             gae.mergeInto(new GigiApiException("You must enter the date when you met the applicant."));
         } else {
             try {
-                Date d = DateSelector.getDateFormat().parse(date);
-                Calendar gc = GregorianCalendar.getInstance();
-                gc.setTimeInMillis(System.currentTimeMillis());
-                gc.add(Calendar.HOUR_OF_DAY, 12);
-                if (d.getTime() > gc.getTimeInMillis()) {
+                DayDate d = new DayDate(DateSelector.getDateFormat().parse(date).getTime());
+                if (d.start().getTime() > System.currentTimeMillis()) {
                     gae.mergeInto(new GigiApiException("You must not enter a date in the future."));
                 }
+                Calendar gc = GregorianCalendar.getInstance();
                 gc.setTimeInMillis(System.currentTimeMillis());
                 gc.add(Calendar.MONTH, -LIMIT_MAX_MONTHS_VERIFICATION);
                 if (d.getTime() < gc.getTimeInMillis()) {
@@ -212,8 +209,8 @@ public class Notary {
             }
             return;
         } else if (t == VerificationType.TTP_ASSISTED) {
-            if ( !agent.isInGroup(Group.TTP_AGENT)) {
-                throw new GigiApiException("RA Agent needs to be TTP RA Agent.");
+            if ( !agent.isInGroup(Group.TTP_AGENT) || !agent.hasValidTTPAgentChallenge()) {
+                throw new GigiApiException("RA Agent needs to be TTP RA Agent and have a valid TTP RA Agent Challenge.");
             }
             if ( !applicant.isInGroup(Group.TTP_APPLICANT)) {
                 throw new GigiApiException("Applicant needs to be TTP Applicant.");