]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/util/Notary.java
add: make "time conditions" configurable
[gigi.git] / src / org / cacert / gigi / util / Notary.java
index 0ecc14e444fb3db2e96cdbe886f737d7abb2ec0f..620eb89cb456b44bddc1760dfe5459a8b2fc4393 100644 (file)
@@ -17,7 +17,13 @@ import org.cacert.gigi.output.template.SprintfCommand;
 
 public class Notary {
 
-    public final static int LIMIT_DAYS_VERIFICATION = 90; // conf.getProperty("limit_days_verification");
+    // minimum date range between 2 verifications of the RA-Agent to the same
+    // Applicant
+    public final static int LIMIT_DAYS_VERIFICATION = TimeConditions.getInstance().getVerificationLimitDays();
+
+    // maximum date range from date when the verification took place and the
+    // entering to the system
+    public final static int LIMIT_MAX_MONTHS_VERIFICATION = TimeConditions.getInstance().getVerificationMaxAgeMonths();
 
     public static void writeUserAgreement(User member, String document, String method, String comment, boolean active, int secmemid) {
         try (GigiPreparedStatement q = new GigiPreparedStatement("INSERT INTO `user_agreements` SET `memid`=?, `secmemid`=?," + " `document`=?,`date`=NOW(), `active`=?,`method`=?,`comment`=?")) {
@@ -85,6 +91,11 @@ public class Notary {
                 if (d.getTime() > gc.getTimeInMillis()) {
                     gae.mergeInto(new GigiApiException("You must not enter a date in the future."));
                 }
+                gc.setTimeInMillis(System.currentTimeMillis());
+                gc.add(Calendar.MONTH, -LIMIT_MAX_MONTHS_VERIFICATION);
+                if (d.getTime() < gc.getTimeInMillis()) {
+                    gae.mergeInto(new GigiApiException(SprintfCommand.createSimple("Verifications older than {0} months are not accepted.", LIMIT_MAX_MONTHS_VERIFICATION)));
+                }
             } catch (ParseException e) {
                 gae.mergeInto(new GigiApiException("You must enter the date in this format: YYYY-MM-DD."));
             }