1 package club.wpia.gigi.util;
3 import java.util.Properties;
5 import club.wpia.gigi.dbObjects.CATS;
7 public class TimeConditions {
9 private static TimeConditions instance;
11 private final int testValidMonths;
13 private final int reverificationDays;
15 private final int verificationFreshMonths;
17 private final int verificationMaxAgeMonths;
19 private final int emailPingMonths;
21 private TimeConditions(Properties ppts) {
22 testValidMonths = Integer.parseInt(ppts.getProperty("time.testValidMonths", "12"));
23 reverificationDays = Integer.parseInt(ppts.getProperty("time.reverificationDays", "90"));
24 verificationFreshMonths = Integer.parseInt(ppts.getProperty("time.verificationFreshMonths", "27"));
25 verificationMaxAgeMonths = Integer.parseInt(ppts.getProperty("time.verificationMaxAgeMonths", "24"));
26 emailPingMonths = Integer.parseInt(ppts.getProperty("time.emailPingMonths", "6"));
29 public static synchronized TimeConditions getInstance() {
30 if (instance == null) {
31 throw new IllegalStateException("TimeConditions class not yet initialised.");
36 public static synchronized final void init(Properties ppts) {
37 if (instance != null) {
38 throw new IllegalStateException("TimeConditions class already initialised.");
40 instance = new TimeConditions(ppts);
44 * Maximum time in months that a passed {@link CATS} test is considered
47 * @return the configured number of months
49 public int getTestMonths() {
50 return testValidMonths;
54 * Minimum time in days that needs to have passed in order to verify a name
57 * @return the configured number of days
59 public int getVerificationLimitDays() {
60 return reverificationDays;
64 * Maximum time in months that a verification is considered recent.
66 * @return the configured number of months
68 public int getVerificationMonths() {
69 return verificationFreshMonths;
73 * Maximum time in months that a verification can be entered after it
74 * occurred. Assuming that the RA-Agent enters the correct date.
76 * @return the configured number of months
78 public int getVerificationMaxAgeMonths() {
79 return verificationMaxAgeMonths;
83 * Maximum time in months that an email address can be used for creating
84 * client certificates before a reping is neccessary
86 * @return the configured number of months
88 public int getEmailPingMonths() {
89 return emailPingMonths;