]> WPIA git - gigi.git/blob - src/org/cacert/gigi/util/TimeConditions.java
Add a hint what the "Request reping" is used for on the email page
[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 final int emailPingMonths;
20
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", "39"));
25         verificationMaxAgeMonths = Integer.parseInt(ppts.getProperty("time.verificationMaxAgeMonths", "24"));
26         emailPingMonths = Integer.parseInt(ppts.getProperty("time.emailPingMonths", "6"));
27     }
28
29     public static synchronized TimeConditions getInstance() {
30         if (instance == null) {
31             throw new IllegalStateException("TimeConditions class not yet initialised.");
32         }
33         return instance;
34     }
35
36     public static synchronized final void init(Properties ppts) {
37         if (instance != null) {
38             throw new IllegalStateException("TimeConditions class already initialised.");
39         }
40         instance = new TimeConditions(ppts);
41     }
42
43     /**
44      * Maximum time in months that a passed {@link CATS} test is considered
45      * recent.
46      * 
47      * @return the configured number of months
48      */
49     public int getTestMonths() {
50         return testValidMonths;
51     }
52
53     /**
54      * Minimum time in days that needs to have passed in order to verify a name
55      * again.
56      * 
57      * @return the configured number of days
58      */
59     public int getVerificationLimitDays() {
60         return reverificationDays;
61     }
62
63     /**
64      * Maximum time in months that a verification is considered recent.
65      * 
66      * @return the configured number of months
67      */
68     public int getVerificationMonths() {
69         return verificationFreshMonths;
70     }
71
72     /**
73      * Maximum time in months that a verification can be entered after it
74      * occurred. Assuming that the RA-Agent enters the correct date.
75      * 
76      * @return the configured number of months
77      */
78     public int getVerificationMaxAgeMonths() {
79         return verificationMaxAgeMonths;
80     }
81
82     /**
83      * Maximum time in months that an email address can be used for creating
84      * client certificates before a reping is neccessary
85      * 
86      * @return the configured number of months
87      */
88     public int getEmailPingMonths() {
89         return emailPingMonths;
90     }
91 }