]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/User.java
add: check DoB upper limit
[gigi.git] / src / org / cacert / gigi / dbObjects / User.java
index e5175694ed1b8ac1083ad728de76740a283d4cc9..4312d9acd00a897e7a2159b0b6f34442ed9d978a 100644 (file)
@@ -43,6 +43,8 @@ public class User extends CertificateOwner {
 
     public static final int MINIMUM_AGE = 16;
 
+    public static final int MAXIMUM_PLAUSIBLE_AGE = 110;
+
     public static final int POJAM_AGE = 14;
 
     public static final int ADULT_AGE = 18;
@@ -136,6 +138,14 @@ public class User extends CertificateOwner {
             if (getReceivedAssurances().length != 0) {
                 throw new GigiApiException("No change after assurance allowed.");
             }
+
+            if ( !CalendarUtil.isOfAge(dob, User.MINIMUM_AGE)) {
+                throw new GigiApiException("Entered date of birth is below the restricted age requirements.");
+            }
+
+            if (CalendarUtil.isOfAge(dob, User.MAXIMUM_PLAUSIBLE_AGE)) {
+                throw new GigiApiException("Entered date of birth exceeds the maximum age set in our policies. Please check your DoB is correct and contact support if the issue persists.");
+            }
             this.dob = dob;
             rawUpdateUserData();
         }