Roberto Sánchez
2014-09-18 e1743c557079051217d1e65901f4ae9f9dad7d00
#0 feature - Fixed some SonarQube issues
6 files modified
changed files
pom.xml patch | view | blame | history
src/main/java/net/curisit/securis/LicenseValidator.java patch | view | blame | history
src/main/java/net/curisit/securis/ReqGenerator.java patch | view | blame | history
src/main/java/net/curisit/securis/beans/LicenseBean.java patch | view | blame | history
src/main/java/net/curisit/securis/beans/RequestBean.java patch | view | blame | history
src/main/java/net/curisit/securis/utils/JsonUtils.java patch | view | blame | history
pom.xml
....@@ -76,7 +76,7 @@
7676 <uniqueVersion>true</uniqueVersion>
7777 <id>curistecSnapshot</id>
7878 <name>CurisTec Snapshots</name>
79
- <url>http://92.54.10.233:48080/archiva/repository/snapshots/</url>
79
+ <url>http://10.0.0.12:8080/archiva/repository/snapshots/</url>
8080 <layout>default</layout>
8181 </snapshotRepository>
8282 </distributionManagement>
src/main/java/net/curisit/securis/LicenseValidator.java
....@@ -17,13 +17,13 @@
1717 private static final Logger log = LogManager.getLogger(LicenseValidator.class);
1818
1919 public static LicenseValidator singleton = new LicenseValidator();
20
- private byte[] LOGO_SECRET;
20
+ public static byte[] LOGO_SECRET;
2121
2222 private LicenseValidator() {
2323 try {
2424 LOGO_SECRET = "Logo ipsum s3cr3t test áíóú".getBytes("utf-8");
2525 } catch (UnsupportedEncodingException e) {
26
- e.printStackTrace();
26
+ log.error("Unexpected error getting LOGO secret", e);
2727 }
2828 }
2929
src/main/java/net/curisit/securis/ReqGenerator.java
....@@ -23,14 +23,7 @@
2323
2424 private static ReqGenerator singleton = new ReqGenerator();
2525
26
- private byte[] LOGO_SECRET;
27
-
2826 private ReqGenerator() {
29
- try {
30
- LOGO_SECRET = "Logo ipsum s3cr3t test áíóú".getBytes("utf-8");
31
- } catch (UnsupportedEncodingException e) {
32
- e.printStackTrace();
33
- }
3427 }
3528
3629 public static ReqGenerator getInstance() {
....@@ -91,7 +84,7 @@
9184 if (is == null)
9285 return null;
9386 try {
94
- String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LOGO_SECRET);
87
+ String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LicenseValidator.LOGO_SECRET);
9588 return shaLogo;
9689 } catch (IOException e) {
9790 log.error("Customer logo was not found in classpath in " + logResource, e);
src/main/java/net/curisit/securis/beans/LicenseBean.java
....@@ -62,6 +62,16 @@
6262 }
6363
6464 @Override
65
+ public int hashCode() {
66
+ int code = 0;
67
+ code += expirationDate != null ? expirationDate.hashCode() : 0;
68
+ code += signature != null ? signature.hashCode() : 0;
69
+ code += metadata != null ? metadata.hashCode() : 0;
70
+
71
+ return code;
72
+ };
73
+
74
+ @Override
6575 public boolean equals(Object obj) {
6676 if (!(obj instanceof LicenseBean))
6777 return false;
src/main/java/net/curisit/securis/beans/RequestBean.java
....@@ -84,6 +84,20 @@
8484 return false;
8585 }
8686
87
+
88
+ @Override
89
+ public int hashCode() {
90
+ int code = 0;
91
+ code += appCode != null ? appCode.hashCode() : 0;
92
+ code += arch != null ? arch.hashCode() : 0;
93
+ code += crcLogo != null ? crcLogo.hashCode() : 0;
94
+ code += customerCode != null ? customerCode.hashCode() : 0;
95
+ code += osName != null ? osName.hashCode() : 0;
96
+ code += macAddresses != null ? macAddresses.hashCode() : 0;
97
+
98
+ return code;
99
+ };
100
+
87101 @Override
88102 public boolean equals(Object obj) {
89103 if (!(obj instanceof RequestBean))
src/main/java/net/curisit/securis/utils/JsonUtils.java
....@@ -197,7 +197,7 @@
197197 } catch (JsonParseException e) {
198198 throw new SeCurisException("Error converting JSON to object", e);
199199 } catch (IOException e) {
200
- e.printStackTrace();
200
+ log.error("Error converting JSON to object", e);
201201 throw new SeCurisException("Error converting JSON to object", e);
202202 }
203203 }