rsanchez
2015-09-25 99e64ffd78b36efaee558a991d4d2ad5abb7ceed
#2756 fix - Updated token for client API
3 files modified
changed files
pom.xml patch | view | blame | history
src/main/java/net/curisit/securis/ConnectionManager.java patch | view | blame | history
src/main/java/net/curisit/securis/LicenseValidator.java patch | view | blame | history
pom.xml
....@@ -3,7 +3,7 @@
33 <modelVersion>4.0.0</modelVersion>
44 <groupId>net.curisit</groupId>
55 <artifactId>securis-client</artifactId>
6
- <version>1.1.0-SNAPSHOT</version>
6
+ <version>1.1.1-SNAPSHOT</version>
77 <build>
88 <plugins>
99 <plugin>
src/main/java/net/curisit/securis/ConnectionManager.java
....@@ -40,7 +40,7 @@
4040 private static final String ERROR_CODE_MESSAGE_HEADER = "X-SECURIS-ERROR-CODE";
4141 private static final String TOKEN_HEADER = "X-SECURIS-TOKEN";
4242
43
- private static final String API_CLIENT_TOKEN = "OTk3ODRiMzY5NzQ5MWI5NmYyZGQyODRiYjY2ZTU2YzdmMTZjYzM3YTY3N2ExM2M3ODI2MjU5ZTMzOTIyYjUzNSBfY2xpZW50IDE5NzAtMDEtMDFUMDA6NTk6NTkuOTk5KzAxMDA=";
43
+ private static final String API_CLIENT_TOKEN = "NjdiMGVjN2ZlYjQ2MjI4ZjQwOGU4MDE2OTQ3YjdjMzJkZTEwMDdlZmZjODJjMWNhZmQyM2UwMGZjMDBkZDExNyBfY2xpZW50IDE5NjktMTItMzFUMjM6NTk6NTkuOTk5KzAwMDA=";
4444 private static ConnectionManager singleton;
4545
4646 private final String serverUrl;
src/main/java/net/curisit/securis/LicenseValidator.java
....@@ -3,6 +3,7 @@
33 import java.io.IOException;
44 import java.io.InputStream;
55 import java.io.UnsupportedEncodingException;
6
+import java.util.UUID;
67
78 import net.curisit.securis.beans.RequestBean;
89 import net.curisit.securis.utils.JsonUtils;
....@@ -14,64 +15,72 @@
1415
1516 public class LicenseValidator {
1617
17
- private static final Logger LOG = LogManager.getLogger(LicenseValidator.class);
18
+ private static final Logger LOG = LogManager.getLogger(LicenseValidator.class);
1819
19
- private static LicenseValidator singleton = new LicenseValidator();
20
- protected static byte[] LOGO_SECRET;
20
+ private static LicenseValidator singleton = new LicenseValidator();
21
+ protected static byte[] LOGO_SECRET;
2122
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
- }
23
+ static {
24
+ try {
25
+ LOGO_SECRET = "Logo ipsum s3cr3t test áíóú".getBytes("utf-8");
26
+ } catch (UnsupportedEncodingException e) {
27
+ LOG.error("Unexpected error getting LOGO secret", e);
28
+ }
29
+ }
2930
30
- private LicenseValidator() {
31
- }
31
+ private LicenseValidator() {
32
+ }
3233
33
- public static LicenseValidator getInstance() {
34
- return singleton;
35
- }
34
+ public static LicenseValidator getInstance() {
35
+ return singleton;
36
+ }
3637
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
- }
38
+ /**
39
+ * @return CRC string for customer logo
40
+ */
41
+ public String getCrcLogo() {
42
+ InputStream is = getClass().getClassLoader().getResourceAsStream("images/logo_customer.png");
43
+ try {
44
+ String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LOGO_SECRET);
45
+ return shaLogo;
46
+ } catch (IOException e) {
47
+ LOG.warn("Customer logo was not found in images/logo_customer.png");
48
+ return null;
49
+ }
50
+ }
5051
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
- }
52
+ public void validateLogo(RequestBean reqBean) throws SeCurisException {
53
+ if (reqBean.getCrcLogo() == null) {
54
+ LOG.info("Customer logo is not included in license file and won't be validated");
55
+ } else {
56
+ String currentCRC = getCrcLogo();
57
+ if (!currentCRC.equals(reqBean.getCrcLogo()))
58
+ throw new SeCurisException("License logo validation failed for request data: " + JsonUtils.toJSON(reqBean));
59
+ }
60
+ }
6061
61
- public void validateHW(RequestBean reqBean, String licTypeCode, String customerCode, String packCode) throws SeCurisException {
62
- RequestBean currentHW = ReqGenerator.getInstance().createRequest(licTypeCode, customerCode, packCode);
63
- if (!currentHW.match(reqBean)) {
64
- throw new SeCurisException("Current System info mismatch the License System info:\n Licensed: \n"
65
- + JsonUtils.toPrettyJSON(reqBean, RequestBean.class) + "\n Expected: \n" + JsonUtils.toPrettyJSON(currentHW));
66
- }
67
- }
62
+ public void validateHW(RequestBean reqBean, String licTypeCode, String customerCode, String packCode) throws SeCurisException {
63
+ RequestBean currentHW = ReqGenerator.getInstance().createRequest(licTypeCode, customerCode, packCode);
64
+ if (!currentHW.match(reqBean)) {
65
+ throw new SeCurisException("Current System info mismatch the License System info:\n Licensed: \n" + JsonUtils.toPrettyJSON(reqBean, RequestBean.class)
66
+ + "\n Expected: \n" + JsonUtils.toPrettyJSON(currentHW));
67
+ }
68
+ }
6869
69
- public void validateHW(RequestBean reqBean, String appCode, String activationCode) throws SeCurisException {
70
- RequestBean currentHW = ReqGenerator.getInstance().createRequest(appCode, activationCode);
71
- if (!currentHW.match(reqBean)) {
72
- throw new SeCurisException("Current System info mismatch the License System info:\n Licensed: \n"
73
- + JsonUtils.toPrettyJSON(reqBean, RequestBean.class) + "\n Expected: \n" + JsonUtils.toPrettyJSON(currentHW));
74
- }
75
- }
70
+ public void validateHW(RequestBean reqBean, String appCode, String activationCode) throws SeCurisException {
71
+ RequestBean currentHW = ReqGenerator.getInstance().createRequest(appCode, activationCode);
72
+ if (!currentHW.match(reqBean)) {
73
+ throw new SeCurisException("Current System info mismatch the License System info:\n Licensed: \n" + JsonUtils.toPrettyJSON(reqBean, RequestBean.class)
74
+ + "\n Expected: \n" + JsonUtils.toPrettyJSON(currentHW));
75
+ }
76
+ }
7677
78
+ public static boolean isValidActivationCode(String activationCode) {
79
+ try {
80
+ UUID.fromString(activationCode);
81
+ return true;
82
+ } catch (Exception ex) {
83
+ return false;
84
+ }
85
+ }
7786 }