rsanchez
2014-09-30 f1702d6537568b1677254e27d772d6aa6d658e2c
src/main/java/net/curisit/securis/License.java
....@@ -73,6 +73,9 @@
7373 if (filename == null)
7474 filename = "./license.lic";
7575 File file = new File(filename);
76
+ if (!file.exists()) {
77
+ throw new SeCurisException("The license file doesn't exist: " + file.getAbsolutePath());
78
+ }
7679 try {
7780 LicenseManager.getInstance().validateLicense(file);
7881 LOG.info("License file {} is valid", file.getAbsolutePath());
....@@ -86,7 +89,7 @@
8689
8790 if (cmd.hasOption('c')) {
8891 SignedLicenseBean lic = LicenseManager.getInstance().requestLicense();
89
- String filename = cmd.getOptionValue("lic_file");
92
+ String filename = cmd.getOptionValue("c");
9093 if (filename == null)
9194 filename = "./license.lic";
9295 File file = new File(filename);
....@@ -105,7 +108,16 @@
105108 if (cmd.hasOption('r')) {
106109 String licFilename = cmd.getOptionValue("renew");
107110 checkMandatoryParameter(licFilename, "renew");
108
- LOG.warn("This command is not yet implemented");
111
+ File file = new File(licFilename);
112
+ if (!file.exists()) {
113
+ throw new SeCurisException("The license file doesn't exist: " + file.getAbsolutePath());
114
+ }
115
+ SignedLicenseBean newLic = LicenseManager.getInstance().renew(file);
116
+ File oldLicFile = new File(file.getAbsoluteFile() + ".old");
117
+ file.renameTo(oldLicFile);
118
+ LOG.info("Old license file has been renamed to: {}", oldLicFile.getAbsolutePath());
119
+ LicenseManager.getInstance().save(newLic, file);
120
+ LOG.info("New license file saved as: {}", file.getAbsolutePath());
109121 System.exit(0);
110122 }
111123