X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FUser.java;h=b492de48525130148b3bc1ac9f919449f5bc637f;hb=35733d6e3c2b8706de5739d3d1ef6cc93a8ea5f6;hp=f43bcdcfc78b0608485addae453c6837ad1f84f9;hpb=9ece5b79f093ac7c91381772ffe595f8f784e477;p=gigi.git diff --git a/src/org/cacert/gigi/User.java b/src/org/cacert/gigi/User.java index f43bcdcf..b492de48 100644 --- a/src/org/cacert/gigi/User.java +++ b/src/org/cacert/gigi/User.java @@ -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; }