Roberto Sánchez
2014-02-24 f7be2173201d6ef2d559ef4e8fdfef5534eee29e
src/main/java/net/curisit/securis/LicenseValidator.java
....@@ -4,20 +4,27 @@
44 import java.io.InputStream;
55 import java.io.UnsupportedEncodingException;
66
7
+import net.curisit.securis.beans.RequestBean;
8
+import net.curisit.securis.utils.JsonUtils;
79 import net.curisit.securis.utils.LicUtils;
810
911 import org.apache.commons.io.IOUtils;
1012
1113 public class LicenseValidator {
1214
15
+ public static LicenseValidator singleton = new LicenseValidator();
1316 private byte[] LOGO_SECRET;
1417
15
- public LicenseValidator() {
18
+ private LicenseValidator() {
1619 try {
1720 LOGO_SECRET = "Logo ipsum s3cr3t test áíóú".getBytes("utf-8");
1821 } catch (UnsupportedEncodingException e) {
1922 e.printStackTrace();
2023 }
24
+ }
25
+
26
+ public static LicenseValidator getInstance() {
27
+ return singleton;
2128 }
2229
2330 /**
....@@ -33,4 +40,17 @@
3340 return null;
3441 }
3542 }
43
+
44
+ public void validateLogo(RequestBean reqBean) throws SeCurisException {
45
+ String currentCRC = getCrcLogo();
46
+ if (!currentCRC.equals(reqBean.getCrcLogo()))
47
+ throw new SeCurisException("License logo validation failed for request data: " + JsonUtils.toJSON(reqBean));
48
+ }
49
+
50
+ public void validateHW(RequestBean reqBean, String appCode, String customerCode) throws SeCurisException {
51
+ RequestBean currentHW = ReqGenerator.getInstance().createRequest(appCode, customerCode);
52
+ if (!currentHW.match(reqBean))
53
+ throw new SeCurisException("Current System info mismatch the License System info: " + JsonUtils.toJSON(reqBean));
54
+ }
55
+
3656 }