From 09bb2b3b9300e332f8b743481fbb412df8cd2a89 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Wed, 22 Oct 2014 16:07:15 +0000
Subject: [PATCH] #2021 feature - Added changes on client to use PackID and other changes related with license file fields
---
src/main/java/net/curisit/securis/ReqGenerator.java | 123 ++++++++++++++++++++--------------------
1 files changed, 62 insertions(+), 61 deletions(-)
diff --git a/src/main/java/net/curisit/securis/ReqGenerator.java b/src/main/java/net/curisit/securis/ReqGenerator.java
index 38716bc..d486a63 100644
--- a/src/main/java/net/curisit/securis/ReqGenerator.java
+++ b/src/main/java/net/curisit/securis/ReqGenerator.java
@@ -19,76 +19,77 @@
public class ReqGenerator {
- private static final Logger LOG = LogManager.getLogger(ReqGenerator.class);
+ private static final Logger LOG = LogManager.getLogger(ReqGenerator.class);
- private static ReqGenerator singleton = new ReqGenerator();
+ private static ReqGenerator singleton = new ReqGenerator();
- private ReqGenerator() {
- }
+ private ReqGenerator() {
+ }
- public static ReqGenerator getInstance() {
- return singleton;
- }
+ public static ReqGenerator getInstance() {
+ return singleton;
+ }
- public RequestBean createRequest(String appCode, String customerCode) throws SeCurisException {
- RequestBean req = new RequestBean();
+ public RequestBean createRequest(String licTypeCode, String customerCode, String packCode) throws SeCurisException {
+ RequestBean req = new RequestBean();
- req.setAppCode(appCode);
- req.setCustomerCode(customerCode);
- req.setArch(HWInfo.getArch());
- req.setCrcLogo(getCrcLogo());
- req.setMacAddresses(HWInfo.getMACAddress());
- req.setOsName(HWInfo.getOsName());
+ req.setLicenseTypeCode(licTypeCode);
+ req.setCustomerCode(customerCode);
+ req.setPackCode(packCode);
+ req.setArch(HWInfo.getArch());
+ req.setCrcLogo(getCrcLogo());
+ req.setMacAddresses(HWInfo.getMACAddress());
+ req.setOsName(HWInfo.getOsName());
- return req;
- }
+ return req;
+ }
- public RequestBean loadRequest(File requestFile) throws SeCurisException {
- try {
- String json = new String(Files.readAllBytes(Paths.get(requestFile.toURI())), "utf-8");
- RequestBean req = JsonUtils.json2object(json, RequestBean.class);
- return req;
- } catch (IOException e) {
- LOG.error("Request file {} was not found or is not accesible");
- throw new SeCurisException("ERROR accesing request file: " + requestFile.getAbsolutePath(), e);
- }
- }
+ public RequestBean loadRequest(File requestFile) throws SeCurisException {
+ try {
+ String json = new String(Files.readAllBytes(Paths.get(requestFile.toURI())), "utf-8");
+ RequestBean req = JsonUtils.json2object(json, RequestBean.class);
+ return req;
+ } catch (IOException e) {
+ LOG.error("Request file {} was not found or is not accesible");
+ throw new SeCurisException("ERROR accesing request file: " + requestFile.getAbsolutePath(), e);
+ }
+ }
- /**
- * Generate a request file using a {@link RequestBean}
- *
- * @param req
- * @param file
- * @throws SeCurisException
- */
- public void save(RequestBean req, File file) throws SeCurisException {
- byte[] json;
- try {
- json = JsonUtils.toJSON(req, true).getBytes("utf-8");
- Files.write(Paths.get(file.toURI()), json, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
- } catch (UnsupportedEncodingException e) {
- LOG.error("Error creating json doc from request: " + req, e);
- throw new SeCurisException("Error creating json doc from request: " + req, e);
- } catch (IOException e) {
- LOG.error("Error creating request file: " + file, e);
- throw new SeCurisException("Error creating request file: " + file, e);
- }
+ /**
+ * Generate a request file using a {@link RequestBean}
+ *
+ * @param req
+ * @param file
+ * @throws SeCurisException
+ */
+ public void save(RequestBean req, File file) throws SeCurisException {
+ byte[] json;
+ try {
+ json = JsonUtils.toJSON(req, true).getBytes("utf-8");
+ Files.write(Paths.get(file.toURI()), json, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
+ } catch (UnsupportedEncodingException e) {
+ LOG.error("Error creating json doc from request: " + req, e);
+ throw new SeCurisException("Error creating json doc from request: " + req, e);
+ } catch (IOException e) {
+ LOG.error("Error creating request file: " + file, e);
+ throw new SeCurisException("Error creating request file: " + file, e);
+ }
- LOG.debug("License saved in {}", file);
+ LOG.debug("License saved in {}", file);
- }
+ }
- private String getCrcLogo() {
- String logResource = "images/logo_customer.png";
- InputStream is = getClass().getClassLoader().getResourceAsStream(logResource);
- if (is == null)
- return null;
- try {
- String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LicenseValidator.LOGO_SECRET);
- return shaLogo;
- } catch (IOException e) {
- LOG.error("Customer logo was not found in classpath in " + logResource, e);
- return null;
- }
- }
+ private String getCrcLogo() {
+ String logResource = "images/logo_customer.png";
+ InputStream is = getClass().getClassLoader().getResourceAsStream(logResource);
+ if (is == null)
+ return null;
+ try {
+ String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LicenseValidator.LOGO_SECRET);
+ return shaLogo;
+ } catch (IOException e) {
+ LOG.error("Customer logo was not found in classpath in " + logResource, e);
+ return null;
+ }
+ }
}
--
Gitblit v1.3.2