From 99e64ffd78b36efaee558a991d4d2ad5abb7ceed Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Fri, 25 Sep 2015 14:45:32 +0000
Subject: [PATCH] #2756 fix - Updated token for client API

---
 src/main/java/net/curisit/securis/LicenseValidator.java  |  111 ++++++++++++++++++++++++++++++-------------------------
 src/main/java/net/curisit/securis/ConnectionManager.java |    2 
 pom.xml                                                  |    2 
 3 files changed, 62 insertions(+), 53 deletions(-)

diff --git a/pom.xml b/pom.xml
index 722d682..ddef0c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>net.curisit</groupId>
 	<artifactId>securis-client</artifactId>
-	<version>1.1.0-SNAPSHOT</version>
+	<version>1.1.1-SNAPSHOT</version>
 	<build>
 		<plugins>
 			<plugin>
diff --git a/src/main/java/net/curisit/securis/ConnectionManager.java b/src/main/java/net/curisit/securis/ConnectionManager.java
index 881ff69..946d142 100644
--- a/src/main/java/net/curisit/securis/ConnectionManager.java
+++ b/src/main/java/net/curisit/securis/ConnectionManager.java
@@ -40,7 +40,7 @@
     private static final String ERROR_CODE_MESSAGE_HEADER = "X-SECURIS-ERROR-CODE";
     private static final String TOKEN_HEADER = "X-SECURIS-TOKEN";
 
-    private static final String API_CLIENT_TOKEN = "OTk3ODRiMzY5NzQ5MWI5NmYyZGQyODRiYjY2ZTU2YzdmMTZjYzM3YTY3N2ExM2M3ODI2MjU5ZTMzOTIyYjUzNSBfY2xpZW50IDE5NzAtMDEtMDFUMDA6NTk6NTkuOTk5KzAxMDA=";
+    private static final String API_CLIENT_TOKEN = "NjdiMGVjN2ZlYjQ2MjI4ZjQwOGU4MDE2OTQ3YjdjMzJkZTEwMDdlZmZjODJjMWNhZmQyM2UwMGZjMDBkZDExNyBfY2xpZW50IDE5NjktMTItMzFUMjM6NTk6NTkuOTk5KzAwMDA=";
     private static ConnectionManager singleton;
 
     private final String serverUrl;
diff --git a/src/main/java/net/curisit/securis/LicenseValidator.java b/src/main/java/net/curisit/securis/LicenseValidator.java
index 0a31755..130a20c 100644
--- a/src/main/java/net/curisit/securis/LicenseValidator.java
+++ b/src/main/java/net/curisit/securis/LicenseValidator.java
@@ -3,6 +3,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+import java.util.UUID;
 
 import net.curisit.securis.beans.RequestBean;
 import net.curisit.securis.utils.JsonUtils;
@@ -14,64 +15,72 @@
 
 public class LicenseValidator {
 
-    private static final Logger LOG = LogManager.getLogger(LicenseValidator.class);
+	private static final Logger LOG = LogManager.getLogger(LicenseValidator.class);
 
-    private static LicenseValidator singleton = new LicenseValidator();
-    protected static byte[] LOGO_SECRET;
+	private static LicenseValidator singleton = new LicenseValidator();
+	protected static byte[] LOGO_SECRET;
 
-    static {
-        try {
-            LOGO_SECRET = "Logo ipsum s3cr3t test áíóú".getBytes("utf-8");
-        } catch (UnsupportedEncodingException e) {
-            LOG.error("Unexpected error getting LOGO secret", e);
-        }
-    }
+	static {
+		try {
+			LOGO_SECRET = "Logo ipsum s3cr3t test áíóú".getBytes("utf-8");
+		} catch (UnsupportedEncodingException e) {
+			LOG.error("Unexpected error getting LOGO secret", e);
+		}
+	}
 
-    private LicenseValidator() {
-    }
+	private LicenseValidator() {
+	}
 
-    public static LicenseValidator getInstance() {
-        return singleton;
-    }
+	public static LicenseValidator getInstance() {
+		return singleton;
+	}
 
-    /**
-     * @return CRC string for customer logo
-     */
-    public String getCrcLogo() {
-        InputStream is = getClass().getClassLoader().getResourceAsStream("images/logo_customer.png");
-        try {
-            String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LOGO_SECRET);
-            return shaLogo;
-        } catch (IOException e) {
-            LOG.warn("Customer logo was not found in images/logo_customer.png");
-            return null;
-        }
-    }
+	/**
+	 * @return CRC string for customer logo
+	 */
+	public String getCrcLogo() {
+		InputStream is = getClass().getClassLoader().getResourceAsStream("images/logo_customer.png");
+		try {
+			String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LOGO_SECRET);
+			return shaLogo;
+		} catch (IOException e) {
+			LOG.warn("Customer logo was not found in images/logo_customer.png");
+			return null;
+		}
+	}
 
-    public void validateLogo(RequestBean reqBean) throws SeCurisException {
-        if (reqBean.getCrcLogo() == null) {
-            LOG.info("Customer logo is not included in license file and won't be validated");
-        } else {
-            String currentCRC = getCrcLogo();
-            if (!currentCRC.equals(reqBean.getCrcLogo()))
-                throw new SeCurisException("License logo validation failed for request data: " + JsonUtils.toJSON(reqBean));
-        }
-    }
+	public void validateLogo(RequestBean reqBean) throws SeCurisException {
+		if (reqBean.getCrcLogo() == null) {
+			LOG.info("Customer logo is not included in license file and won't be validated");
+		} else {
+			String currentCRC = getCrcLogo();
+			if (!currentCRC.equals(reqBean.getCrcLogo()))
+				throw new SeCurisException("License logo validation failed for request data: " + JsonUtils.toJSON(reqBean));
+		}
+	}
 
-    public void validateHW(RequestBean reqBean, String licTypeCode, String customerCode, String packCode) throws SeCurisException {
-        RequestBean currentHW = ReqGenerator.getInstance().createRequest(licTypeCode, customerCode, packCode);
-        if (!currentHW.match(reqBean)) {
-            throw new SeCurisException("Current System info mismatch the License System info:\n Licensed: \n"
-                    + JsonUtils.toPrettyJSON(reqBean, RequestBean.class) + "\n Expected: \n" + JsonUtils.toPrettyJSON(currentHW));
-        }
-    }
+	public void validateHW(RequestBean reqBean, String licTypeCode, String customerCode, String packCode) throws SeCurisException {
+		RequestBean currentHW = ReqGenerator.getInstance().createRequest(licTypeCode, customerCode, packCode);
+		if (!currentHW.match(reqBean)) {
+			throw new SeCurisException("Current System info mismatch the License System info:\n Licensed: \n" + JsonUtils.toPrettyJSON(reqBean, RequestBean.class)
+					+ "\n Expected: \n" + JsonUtils.toPrettyJSON(currentHW));
+		}
+	}
 
-    public void validateHW(RequestBean reqBean, String appCode, String activationCode) throws SeCurisException {
-        RequestBean currentHW = ReqGenerator.getInstance().createRequest(appCode, activationCode);
-        if (!currentHW.match(reqBean)) {
-            throw new SeCurisException("Current System info mismatch the License System info:\n Licensed: \n"
-                    + JsonUtils.toPrettyJSON(reqBean, RequestBean.class) + "\n Expected: \n" + JsonUtils.toPrettyJSON(currentHW));
-        }
-    }
+	public void validateHW(RequestBean reqBean, String appCode, String activationCode) throws SeCurisException {
+		RequestBean currentHW = ReqGenerator.getInstance().createRequest(appCode, activationCode);
+		if (!currentHW.match(reqBean)) {
+			throw new SeCurisException("Current System info mismatch the License System info:\n Licensed: \n" + JsonUtils.toPrettyJSON(reqBean, RequestBean.class)
+					+ "\n Expected: \n" + JsonUtils.toPrettyJSON(currentHW));
+		}
+	}
 
+	public static boolean isValidActivationCode(String activationCode) {
+		try {
+			UUID.fromString(activationCode);
+			return true;
+		} catch (Exception ex) {
+			return false;
+		}
+	}
 }

--
Gitblit v1.3.2