1 package org.cacert.gigi.util;
3 import java.util.Properties;
5 import org.cacert.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 TimeConditions(Properties ppts) {
20 testValidMonths = Integer.parseInt(ppts.getProperty("time.testValidMonths", "12"));
21 reverificationDays = Integer.parseInt(ppts.getProperty("time.reverificationDays", "90"));
22 verificationFreshMonths = Integer.parseInt(ppts.getProperty("time.verificationFreshMonths", "39"));
23 verificationMaxAgeMonths = Integer.parseInt(ppts.getProperty("time.verificationMaxAgeMonths", "24"));
26 public static synchronized TimeConditions getInstance() {
27 if (instance == null) {
28 throw new IllegalStateException("TimeConditions class not yet initialised.");
33 public static synchronized final void init(Properties ppts) {
34 if (instance != null) {
35 throw new IllegalStateException("TimeConditions class already initialised.");
37 instance = new TimeConditions(ppts);
41 * Maximum time in months that a passed {@link CATS} test is considered
44 * @return the configured number of months
46 public int getTestMonths() {
47 return testValidMonths;
51 * Minimum time in days that needs to have passed in order to verify a name
54 * @return the configured number of days
56 public int getVerificationLimitDays() {
57 return reverificationDays;
61 * Maximum time in months that a verification is considered recent.
63 * @return the configured number of months
65 public int getVerificationMonths() {
66 return verificationFreshMonths;
70 * Maximum time in months that a verification can be entered after it
71 * occurred. Assuming that the RA-Agent enters the correct date.
73 * @return the configured number of months
75 public int getVerificationMaxAgeMonths() {
76 return verificationMaxAgeMonths;