pom.xml
.. .. @@ -17,11 +17,6 @@ 17 17 </build> 18 18 <dependencies> 19 19 <dependency> 20 - <groupId>org.slf4j</groupId>21 - <artifactId>log4j-over-slf4j</artifactId>22 - <version>1.7.6</version>23 - </dependency>24 - <dependency>25 20 <groupId>org.apache.commons</groupId> 26 21 <artifactId>commons-lang3</artifactId> 27 22 <version>3.2.1</version> .. .. @@ -48,7 +43,12 @@ 48 43 </dependency> 49 44 <dependency> 50 45 <groupId>org.apache.logging.log4j</groupId> 51 - <artifactId>log4j-api</artifactId>46 + <artifactId>log4j-slf4j-impl</artifactId>47 + <version>2.0-rc1</version>48 + </dependency>49 + <dependency>50 + <groupId>org.apache.logging.log4j</groupId>51 + <artifactId>log4j-core</artifactId>52 52 <version>2.0-rc1</version> 53 53 </dependency> 54 54 </dependencies> src/main/java/net/curisit/securis/License.java
.. .. @@ -1,5 +1,9 @@ 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,10 +16,47 @@ 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 parameters48 + */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) { src/main/java/net/curisit/securis/SignatureHelper.java
.. .. @@ -26,7 +26,6 @@ 26 26 27 27 import org.apache.commons.io.FileUtils; 28 28 import org.apache.commons.net.util.Base64; 29 -import org.apache.log4j.xml.DOMConfigurator;30 29 import org.slf4j.Logger; 31 30 import org.slf4j.LoggerFactory; 32 31 .. .. @@ -130,7 +129,7 @@ 130 129 131 130 public static void main(String[] args) throws SeCurisException { 132 131 // org.apache.log4j.Logger.getRootLogger().addAppender(new Appender); 133 - DOMConfigurator.configure("/Users/cproberto/Documents/wsCurisIT/SeCurisClient/src/main/resources/log4j.xml");132 + // DOMConfigurator.configure("/Users/cproberto/Documents/wsCurisIT/SeCurisClient/src/main/resources/log4j.xml");134 133 RequestBean req = ReqGenerator.getInstance().createRequest("CI", "Roberto"); 135 134 136 135 LicenseGenerator lg = LicenseGenerator.getInstance(); src/main/java/net/curisit/securis/utils/Params.java
.. .. @@ -31,6 +31,7 @@ 31 31 loadParameters(KEY_CONFIG_FILE); 32 32 } catch (IOException e) { 33 33 log.error("Config file {} was not found in classpath", KEY_CONFIG_FILE); 34 + System.exit(-2);34 35 } 35 36 } 36 37