| .. | .. |
|---|
| 1 | 1 | package net.curisit.securis; |
|---|
| 2 | 2 | |
|---|
| 3 | +import java.io.File; |
|---|
| 4 | + |
|---|
| 5 | +import net.curisit.securis.utils.Params; |
|---|
| 6 | + |
|---|
| 3 | 7 | import org.apache.commons.cli.CommandLine; |
|---|
| 4 | 8 | import org.apache.commons.cli.CommandLineParser; |
|---|
| 5 | 9 | import org.apache.commons.cli.HelpFormatter; |
|---|
| .. | .. |
|---|
| 12 | 16 | |
|---|
| 13 | 17 | public class License { |
|---|
| 14 | 18 | |
|---|
| 19 | + static { |
|---|
| 20 | + // BasicConfigurator.configure(new ConsoleAppender()); |
|---|
| 21 | + // PropertyConfigurator.configure("/log4j.xml"); |
|---|
| 22 | + // LogManager.getRootLogger(). |
|---|
| 23 | + } |
|---|
| 24 | + |
|---|
| 15 | 25 | private static final Logger log = LoggerFactory.getLogger(License.class); |
|---|
| 16 | 26 | |
|---|
| 17 | 27 | public static void main(String[] args) { |
|---|
| 28 | + log.info("Tool init"); |
|---|
| 29 | + checkConfigFile(); |
|---|
| 18 | 30 | CommandLine cmd = getCommandLine(args); |
|---|
| 31 | + |
|---|
| 32 | + try { |
|---|
| 33 | + if (cmd.hasOption('g')) { |
|---|
| 34 | + String filename = cmd.getOptionValue("rfile"); |
|---|
| 35 | + if (filename == null) |
|---|
| 36 | + filename = "./license.req"; |
|---|
| 37 | + LicenseManager.getInstance().createRequestFile(new File(filename)); |
|---|
| 38 | + System.exit(0); |
|---|
| 39 | + } |
|---|
| 40 | + |
|---|
| 41 | + } catch (SeCurisException e) { |
|---|
| 42 | + log.error("The command generated an error: {}", e.toString()); |
|---|
| 43 | + } |
|---|
| 44 | + } |
|---|
| 45 | + |
|---|
| 46 | + /** |
|---|
| 47 | + * Checks that config file exists and contains mandatory parameters |
|---|
| 48 | + */ |
|---|
| 49 | + private static void checkConfigFile() { |
|---|
| 50 | + String appCode = Params.get(Params.KEYS.APPLICATION_CODE); |
|---|
| 51 | + if (appCode == null) { |
|---|
| 52 | + log.error("Manadatory parameter {} is not set in config file", Params.KEYS.APPLICATION_CODE); |
|---|
| 53 | + System.exit(-3); |
|---|
| 54 | + } |
|---|
| 55 | + String customerCode = Params.get(Params.KEYS.CUSTOMER_CODE); |
|---|
| 56 | + if (customerCode == null) { |
|---|
| 57 | + log.error("Manadatory parameter {} is not set in config file", Params.KEYS.CUSTOMER_CODE); |
|---|
| 58 | + System.exit(-4); |
|---|
| 59 | + } |
|---|
| 19 | 60 | } |
|---|
| 20 | 61 | |
|---|
| 21 | 62 | private static CommandLine getCommandLine(String[] args) { |
|---|