| .. | .. |
|---|
| 3 | 3 | import java.io.File; |
|---|
| 4 | 4 | import java.net.URISyntaxException; |
|---|
| 5 | 5 | |
|---|
| 6 | +import net.curisit.securis.beans.SignedLicenseBean; |
|---|
| 6 | 7 | import net.curisit.securis.utils.Params; |
|---|
| 7 | 8 | |
|---|
| 8 | 9 | import org.apache.commons.cli.CommandLine; |
|---|
| .. | .. |
|---|
| 14 | 15 | import org.apache.commons.cli.PosixParser; |
|---|
| 15 | 16 | import org.apache.logging.log4j.LogManager; |
|---|
| 16 | 17 | import org.apache.logging.log4j.Logger; |
|---|
| 18 | +import org.codehaus.jackson.map.DeserializerFactory.Config; |
|---|
| 17 | 19 | |
|---|
| 18 | 20 | /** |
|---|
| 19 | 21 | * Main class when SeCuris client is used from command line. |
|---|
| .. | .. |
|---|
| 40 | 42 | */ |
|---|
| 41 | 43 | public class License { |
|---|
| 42 | 44 | |
|---|
| 43 | | - private static final Logger LOG = LogManager.getLogger(License.class); |
|---|
| 45 | + private static final Logger LOG = LogManager.getLogger(License.class); |
|---|
| 44 | 46 | |
|---|
| 45 | 47 | /** |
|---|
| 46 | 48 | * Aplication entry point when it used as CLI |
|---|
| .. | .. |
|---|
| 83 | 85 | } |
|---|
| 84 | 86 | |
|---|
| 85 | 87 | if (cmd.hasOption('c')) { |
|---|
| 86 | | - LicenseManager.getInstance().requestLicense(); |
|---|
| 88 | + SignedLicenseBean lic = LicenseManager.getInstance().requestLicense(); |
|---|
| 89 | + String filename = cmd.getOptionValue("lic_file"); |
|---|
| 90 | + if (filename == null) |
|---|
| 91 | + filename = "./license.lic"; |
|---|
| 92 | + File file = new File(filename); |
|---|
| 93 | + LicenseManager.getInstance().save(lic, file); |
|---|
| 94 | + LOG.info("License file sucessfully saved in file: {}", file.getAbsolutePath()); |
|---|
| 87 | 95 | System.exit(0); |
|---|
| 88 | 96 | } |
|---|
| 89 | 97 | |
|---|
| 90 | 98 | if (cmd.hasOption('t')) { |
|---|
| 91 | 99 | LicenseManager.getInstance().testServer(); |
|---|
| 100 | + LOG.info("Server is OK, url: {}", Params.get(Params.KEYS.LICENSE_SERVER_URL, Params.DEFAUT_SERVER_URL)); |
|---|
| 101 | + |
|---|
| 92 | 102 | System.exit(0); |
|---|
| 93 | 103 | } |
|---|
| 94 | 104 | |
|---|
| .. | .. |
|---|
| 163 | 173 | options.addOption(OptionBuilder.withArgName("lic_file").withLongOpt("validate").withDescription("Validate lic file.").hasArg(true).create('l')); |
|---|
| 164 | 174 | |
|---|
| 165 | 175 | options.addOption("g", "gen_request", false, "Generate request file. If --rfile parameter is missing then It is generated in current directory."); |
|---|
| 166 | | - options.addOption(OptionBuilder.withLongOpt("create").withDescription("Request a license file to server.").hasArg(false).create('c')); |
|---|
| 176 | + options.addOption(OptionBuilder.withArgName("lic_file").withLongOpt("create").withDescription("Request a license file to server.").hasArg(true).hasOptionalArg().create('c')); |
|---|
| 167 | 177 | options.addOption("t", "test_lc", false, "Test if License Server (LC) is available. "); |
|---|
| 168 | 178 | options.addOption(OptionBuilder.withArgName("lic_file").withLongOpt("renew").withDescription("Synchronize/renew the current license file.").hasArg(true).create('r')); |
|---|
| 169 | 179 | |
|---|