rsanchez
2014-09-30 f1702d6537568b1677254e27d772d6aa6d658e2c
src/main/java/net/curisit/securis/LicenseManager.java
....@@ -6,6 +6,7 @@
66 import java.nio.file.Files;
77 import java.nio.file.Paths;
88 import java.nio.file.StandardOpenOption;
9
+import java.util.Date;
910
1011 import net.curisit.securis.ConnectionManager.Command;
1112 import net.curisit.securis.beans.LicenseBean;
....@@ -57,29 +58,55 @@
5758 return licBean;
5859 }
5960
60
- /**
61
- * Validates the license stored in {@code licFile} and get the corresponding LicenseBean
62
- * <p>
63
- * The validation includes:
64
- * <ul>
65
- * <li>Signature</li>
66
- * <li>HW data</li>
67
- * <li>Logo CRC</li>
68
- * </ul>
69
- * </p>
70
- *
71
- * @param licFile
72
- * @return The license bean stored in file
73
- * @throws SeCurisException
74
- */
75
- public LicenseBean validateLicense(File licFile) throws SeCurisException {
76
- LicenseBean licBean = load(licFile);
77
- SignatureHelper.getInstance().validateSignature(licBean);
78
- LicenseValidator.getInstance().validateHW(licBean, Params.get(Params.KEYS.APPLICATION_CODE), Params.get(Params.KEYS.CUSTOMER_CODE));
79
- LicenseValidator.getInstance().validateLogo(licBean);
61
+ /**
62
+ * Validates the license stored in {@code licFile} and get the corresponding LicenseBean
63
+ * <p>
64
+ * The validation includes:
65
+ * <ul>
66
+ * <li>Signature</li>
67
+ * <li>HW data</li>
68
+ * <li>Logo CRC</li>
69
+ * </ul>
70
+ * </p>
71
+ *
72
+ * @param licFile
73
+ * @return The license bean stored in file
74
+ * @throws SeCurisException
75
+ */
76
+ public LicenseBean validateLicense(File licFile) throws SeCurisException {
8077
81
- return licBean;
82
- }
78
+ return validateLicense(licFile, false);
79
+ }
80
+
81
+ /**
82
+ * Validates the license stored in {@code licFile} and get the corresponding LicenseBean. The License date is not validated
83
+ * <p>
84
+ * The validation includes:
85
+ * <ul>
86
+ * <li>Signature</li>
87
+ * <li>HW data</li>
88
+ * <li>Logo CRC</li>
89
+ * </ul>
90
+ * </p>
91
+ *
92
+ * @param licFile
93
+ * @return The license bean stored in file
94
+ * @throws SeCurisException
95
+ */
96
+ public LicenseBean validateLicense(File licFile, boolean excludeDateValidation) throws SeCurisException {
97
+ LicenseBean licBean = load(licFile);
98
+ SignatureHelper.getInstance().validateSignature(licBean);
99
+ LicenseValidator.getInstance().validateHW(licBean, Params.get(Params.KEYS.APPLICATION_CODE), Params.get(Params.KEYS.CUSTOMER_CODE));
100
+ LicenseValidator.getInstance().validateLogo(licBean);
101
+
102
+ if (!excludeDateValidation) {
103
+ if (new Date().after(licBean.getExpirationDate())) {
104
+ throw new SeCurisException("License has expired");
105
+ }
106
+ }
107
+
108
+ return licBean;
109
+ }
83110
84111 /**
85112 * Request to server for a valid license