| .. | .. |
|---|
| 1 | 1 | package net.curisit.securis; |
|---|
| 2 | 2 | |
|---|
| 3 | 3 | import java.io.File; |
|---|
| 4 | +import java.net.URISyntaxException; |
|---|
| 5 | +import java.util.Date; |
|---|
| 4 | 6 | |
|---|
| 5 | 7 | import net.curisit.securis.utils.Params; |
|---|
| 6 | 8 | |
|---|
| .. | .. |
|---|
| 11 | 13 | import org.apache.commons.cli.Options; |
|---|
| 12 | 14 | import org.apache.commons.cli.ParseException; |
|---|
| 13 | 15 | import org.apache.commons.cli.PosixParser; |
|---|
| 14 | | -import org.slf4j.Logger; |
|---|
| 15 | | -import org.slf4j.LoggerFactory; |
|---|
| 16 | +import org.apache.logging.log4j.LogManager; |
|---|
| 17 | +import org.apache.logging.log4j.Logger; |
|---|
| 16 | 18 | |
|---|
| 17 | 19 | public class License { |
|---|
| 18 | 20 | |
|---|
| .. | .. |
|---|
| 22 | 24 | // LogManager.getRootLogger(). |
|---|
| 23 | 25 | } |
|---|
| 24 | 26 | |
|---|
| 25 | | - private static final Logger log = LoggerFactory.getLogger(License.class); |
|---|
| 27 | + // private static final Logger log = LoggerFactory.getLogger(License.class); |
|---|
| 28 | + private static final Logger log = LogManager.getLogger(License.class); |
|---|
| 26 | 29 | |
|---|
| 27 | | - public static void main(String[] args) { |
|---|
| 28 | | - log.info("Tool init"); |
|---|
| 30 | + public static void main(String[] args) throws URISyntaxException { |
|---|
| 31 | + // Configuration conf = XMLConfigurationFactory.getInstance().getConfiguration("config", License.class.getResource("/log4j.xml").toURI()); |
|---|
| 32 | + |
|---|
| 33 | + log.info("Tool init {}", new Date()); |
|---|
| 34 | + |
|---|
| 29 | 35 | checkConfigFile(); |
|---|
| 30 | 36 | CommandLine cmd = getCommandLine(args); |
|---|
| 31 | 37 | |
|---|
| .. | .. |
|---|
| 34 | 40 | String filename = cmd.getOptionValue("rfile"); |
|---|
| 35 | 41 | if (filename == null) |
|---|
| 36 | 42 | filename = "./license.req"; |
|---|
| 37 | | - LicenseManager.getInstance().createRequestFile(new File(filename)); |
|---|
| 43 | + File file = new File(filename); |
|---|
| 44 | + LicenseManager.getInstance().createRequestFile(file); |
|---|
| 45 | + log.info("Request file {} generated OK", file.getAbsolutePath()); |
|---|
| 46 | + System.exit(0); |
|---|
| 47 | + } |
|---|
| 48 | + |
|---|
| 49 | + if (cmd.hasOption('l')) { |
|---|
| 50 | + String filename = cmd.getOptionValue("validate"); |
|---|
| 51 | + if (filename == null) |
|---|
| 52 | + filename = "./license.lic"; |
|---|
| 53 | + File file = new File(filename); |
|---|
| 54 | + try { |
|---|
| 55 | + LicenseManager.getInstance().validateLicense(file); |
|---|
| 56 | + log.info("License file {} is valid", file.getAbsolutePath()); |
|---|
| 57 | + } catch (SeCurisException e) { |
|---|
| 58 | + log.info("License file {} is NOT valid", file.getAbsolutePath()); |
|---|
| 59 | + } |
|---|
| 60 | + |
|---|
| 38 | 61 | System.exit(0); |
|---|
| 39 | 62 | } |
|---|
| 40 | 63 | |
|---|