rsanchez
2014-10-22 09bb2b3b9300e332f8b743481fbb412df8cd2a89
src/main/java/net/curisit/securis/LicenseValidator.java
....@@ -14,55 +14,56 @@
1414
1515 public class LicenseValidator {
1616
17
- private static final Logger LOG = LogManager.getLogger(LicenseValidator.class);
17
+ private static final Logger LOG = LogManager.getLogger(LicenseValidator.class);
1818
19
- private static LicenseValidator singleton = new LicenseValidator();
20
- protected static byte[] LOGO_SECRET;
19
+ private static LicenseValidator singleton = new LicenseValidator();
20
+ protected static byte[] LOGO_SECRET;
2121
22
- static {
23
- try {
24
- LOGO_SECRET = "Logo ipsum s3cr3t test áíóú".getBytes("utf-8");
25
- } catch (UnsupportedEncodingException e) {
26
- LOG.error("Unexpected error getting LOGO secret", e);
27
- }
28
- }
22
+ static {
23
+ try {
24
+ LOGO_SECRET = "Logo ipsum s3cr3t test áíóú".getBytes("utf-8");
25
+ } catch (UnsupportedEncodingException e) {
26
+ LOG.error("Unexpected error getting LOGO secret", e);
27
+ }
28
+ }
2929
30
- private LicenseValidator() {
31
- }
30
+ private LicenseValidator() {
31
+ }
3232
33
- public static LicenseValidator getInstance() {
34
- return singleton;
35
- }
33
+ public static LicenseValidator getInstance() {
34
+ return singleton;
35
+ }
3636
37
- /**
38
- * @return CRC string for customer logo
39
- */
40
- public String getCrcLogo() {
41
- InputStream is = getClass().getClassLoader().getResourceAsStream("images/logo_customer.png");
42
- try {
43
- String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LOGO_SECRET);
44
- return shaLogo;
45
- } catch (IOException e) {
46
- LOG.warn("Customer logo was not found in images/logo_customer.png");
47
- return null;
48
- }
49
- }
37
+ /**
38
+ * @return CRC string for customer logo
39
+ */
40
+ public String getCrcLogo() {
41
+ InputStream is = getClass().getClassLoader().getResourceAsStream("images/logo_customer.png");
42
+ try {
43
+ String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LOGO_SECRET);
44
+ return shaLogo;
45
+ } catch (IOException e) {
46
+ LOG.warn("Customer logo was not found in images/logo_customer.png");
47
+ return null;
48
+ }
49
+ }
5050
51
- public void validateLogo(RequestBean reqBean) throws SeCurisException {
52
- if (reqBean.getCrcLogo() == null) {
53
- LOG.info("Customer logo is not included in license file and won't be validated");
54
- } else {
55
- String currentCRC = getCrcLogo();
56
- if (!currentCRC.equals(reqBean.getCrcLogo()))
57
- throw new SeCurisException("License logo validation failed for request data: " + JsonUtils.toJSON(reqBean));
58
- }
59
- }
51
+ public void validateLogo(RequestBean reqBean) throws SeCurisException {
52
+ if (reqBean.getCrcLogo() == null) {
53
+ LOG.info("Customer logo is not included in license file and won't be validated");
54
+ } else {
55
+ String currentCRC = getCrcLogo();
56
+ if (!currentCRC.equals(reqBean.getCrcLogo()))
57
+ throw new SeCurisException("License logo validation failed for request data: " + JsonUtils.toJSON(reqBean));
58
+ }
59
+ }
6060
61
- public void validateHW(RequestBean reqBean, String appCode, String customerCode) throws SeCurisException {
62
- RequestBean currentHW = ReqGenerator.getInstance().createRequest(appCode, customerCode);
63
- if (!currentHW.match(reqBean)) {
64
- throw new SeCurisException("Current System info mismatch the License System info:\n Licensed: " + JsonUtils.toJSON(reqBean, true) + "\n Expected: " + JsonUtils.toJSON(currentHW, true));
65
- }
66
- }
61
+ public void validateHW(RequestBean reqBean, String appCode, String customerCode, String packCode) throws SeCurisException {
62
+ RequestBean currentHW = ReqGenerator.getInstance().createRequest(appCode, customerCode, packCode);
63
+ if (!currentHW.match(reqBean)) {
64
+ throw new SeCurisException("Current System info mismatch the License System info:\n Licensed: " + JsonUtils.toJSON(reqBean, true)
65
+ + "\n Expected: " + JsonUtils.toJSON(currentHW, true));
66
+ }
67
+ }
6768
6869 }