]> WPIA git - gigi.git/blob - src/org/cacert/gigi/util/TimeConditions.java
Highlight expired nucleus bonus verifications in points overview
[gigi.git] / src / org / cacert / gigi / util / TimeConditions.java
1 package org.cacert.gigi.util;
2
3 import java.util.Properties;
4
5 import org.cacert.gigi.dbObjects.CATS;
6
7 public class TimeConditions {
8
9     private static TimeConditions instance;
10
11     private final int testValidMonths;
12
13     private final int reverificationDays;
14
15     private final int verificationFreshMonths;
16
17     private final int verificationMaxAgeMonths;
18
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"));
24     }
25
26     public static synchronized TimeConditions getInstance() {
27         if (instance == null) {
28             throw new IllegalStateException("TimeConditions class not yet initialised.");
29         }
30         return instance;
31     }
32
33     public static synchronized final void init(Properties ppts) {
34         if (instance != null) {
35             throw new IllegalStateException("TimeConditions class already initialised.");
36         }
37         instance = new TimeConditions(ppts);
38     }
39
40     /**
41      * Maximum time in months that a passed {@link CATS} test is considered
42      * recent.
43      * 
44      * @return the configured number of months
45      */
46     public int getTestMonths() {
47         return testValidMonths;
48     }
49
50     /**
51      * Minimum time in days that needs to have passed in order to verify a name
52      * again.
53      * 
54      * @return the configured number of days
55      */
56     public int getVerificationLimitDays() {
57         return reverificationDays;
58     }
59
60     /**
61      * Maximum time in months that a verification is considered recent.
62      * 
63      * @return the configured number of months
64      */
65     public int getVerificationMonths() {
66         return verificationFreshMonths;
67     }
68
69     /**
70      * Maximum time in months that a verification can be entered after it
71      * occurred. Assuming that the RA-Agent enters the correct date.
72      * 
73      * @return the configured number of months
74      */
75     public int getVerificationMaxAgeMonths() {
76         return verificationMaxAgeMonths;
77     }
78
79 }