From f1702d6537568b1677254e27d772d6aa6d658e2c Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Tue, 30 Sep 2014 11:08:45 +0000
Subject: [PATCH] #2021 fix - Added renew command in client
---
src/main/java/net/curisit/securis/License.java | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/main/java/net/curisit/securis/License.java b/src/main/java/net/curisit/securis/License.java
index 2d51327..d22c4cd 100644
--- a/src/main/java/net/curisit/securis/License.java
+++ b/src/main/java/net/curisit/securis/License.java
@@ -73,6 +73,9 @@
if (filename == null)
filename = "./license.lic";
File file = new File(filename);
+ if (!file.exists()) {
+ throw new SeCurisException("The license file doesn't exist: " + file.getAbsolutePath());
+ }
try {
LicenseManager.getInstance().validateLicense(file);
LOG.info("License file {} is valid", file.getAbsolutePath());
@@ -86,7 +89,7 @@
if (cmd.hasOption('c')) {
SignedLicenseBean lic = LicenseManager.getInstance().requestLicense();
- String filename = cmd.getOptionValue("lic_file");
+ String filename = cmd.getOptionValue("c");
if (filename == null)
filename = "./license.lic";
File file = new File(filename);
@@ -105,7 +108,16 @@
if (cmd.hasOption('r')) {
String licFilename = cmd.getOptionValue("renew");
checkMandatoryParameter(licFilename, "renew");
- LOG.warn("This command is not yet implemented");
+ File file = new File(licFilename);
+ if (!file.exists()) {
+ throw new SeCurisException("The license file doesn't exist: " + file.getAbsolutePath());
+ }
+ SignedLicenseBean newLic = LicenseManager.getInstance().renew(file);
+ File oldLicFile = new File(file.getAbsoluteFile() + ".old");
+ file.renameTo(oldLicFile);
+ LOG.info("Old license file has been renamed to: {}", oldLicFile.getAbsolutePath());
+ LicenseManager.getInstance().save(newLic, file);
+ LOG.info("New license file saved as: {}", file.getAbsolutePath());
System.exit(0);
}
--
Gitblit v1.3.2