| .. | .. |
|---|
| 73 | 73 | if (filename == null) |
|---|
| 74 | 74 | filename = "./license.lic"; |
|---|
| 75 | 75 | File file = new File(filename); |
|---|
| 76 | + if (!file.exists()) { |
|---|
| 77 | + throw new SeCurisException("The license file doesn't exist: " + file.getAbsolutePath()); |
|---|
| 78 | + } |
|---|
| 76 | 79 | try { |
|---|
| 77 | 80 | LicenseManager.getInstance().validateLicense(file); |
|---|
| 78 | 81 | LOG.info("License file {} is valid", file.getAbsolutePath()); |
|---|
| .. | .. |
|---|
| 86 | 89 | |
|---|
| 87 | 90 | if (cmd.hasOption('c')) { |
|---|
| 88 | 91 | SignedLicenseBean lic = LicenseManager.getInstance().requestLicense(); |
|---|
| 89 | | - String filename = cmd.getOptionValue("lic_file"); |
|---|
| 92 | + String filename = cmd.getOptionValue("c"); |
|---|
| 90 | 93 | if (filename == null) |
|---|
| 91 | 94 | filename = "./license.lic"; |
|---|
| 92 | 95 | File file = new File(filename); |
|---|
| .. | .. |
|---|
| 105 | 108 | if (cmd.hasOption('r')) { |
|---|
| 106 | 109 | String licFilename = cmd.getOptionValue("renew"); |
|---|
| 107 | 110 | 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()); |
|---|
| 109 | 121 | System.exit(0); |
|---|
| 110 | 122 | } |
|---|
| 111 | 123 | |
|---|