]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/User.java
Document User.getMaxAssurePoints
[gigi.git] / src / org / cacert / gigi / User.java
index f43bcdcfc78b0608485addae453c6837ad1f84f9..b492de48525130148b3bc1ac9f919449f5bc637f 100644 (file)
@@ -4,6 +4,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Date;
+import java.util.Calendar;
 
 import org.cacert.gigi.database.DatabaseConnection;
 import org.cacert.gigi.util.PasswordHash;
@@ -158,9 +159,27 @@ public class User {
                                && dob.toString().equals(s.dob.toString()); // This is due to
                                                                                                                        // day cutoff
        }
+
+       /**
+        * Gets the maximum allowed points NOW. Note that an assurance needs to
+        * re-check PoJam as it has taken place in the past.
+        * 
+        * @return the maximal points
+        * @throws SQLException
+        */
        public int getMaxAssurePoints() throws SQLException {
                int exp = getExperiencePoints();
                int points = 10;
+               Calendar c = Calendar.getInstance();
+               c.setTime(dob);
+               int year = c.get(Calendar.YEAR);
+               int month = c.get(Calendar.MONTH);
+               int day = c.get(Calendar.DAY_OF_MONTH);
+               c.set(year + 18, month, day);
+               if (System.currentTimeMillis() < c.getTime().getTime()) {
+                       return points; // not 18 Years old.
+               }
+
                if (exp >= 10) {
                        points += 5;
                }