#0 feature - Fixed some SonarQube issues
| .. | .. |
|---|
| 3 | 3 | <modelVersion>4.0.0</modelVersion> |
|---|
| 4 | 4 | <groupId>net.curisit</groupId> |
|---|
| 5 | 5 | <artifactId>securis-client</artifactId> |
|---|
| 6 | | - <version>0.9.5-SNAPSHOT</version> |
|---|
| 6 | + <version>0.9.6-SNAPSHOT</version> |
|---|
| 7 | 7 | <build> |
|---|
| 8 | 8 | <plugins> |
|---|
| 9 | 9 | <plugin> |
|---|
| .. | .. |
|---|
| 42 | 42 | */ |
|---|
| 43 | 43 | public class License { |
|---|
| 44 | 44 | |
|---|
| 45 | | - private static final Logger log = LogManager.getLogger(License.class); |
|---|
| 45 | + private static final Logger LOG = LogManager.getLogger(License.class); |
|---|
| 46 | 46 | |
|---|
| 47 | 47 | /** |
|---|
| 48 | 48 | * Aplication entry point when it used as CLI |
|---|
| .. | .. |
|---|
| 51 | 51 | * @throws URISyntaxException |
|---|
| 52 | 52 | */ |
|---|
| 53 | 53 | public static void main(String[] args) throws URISyntaxException { |
|---|
| 54 | | - // Configuration conf = XMLConfigurationFactory.getInstance().getConfiguration("config", License.class.getResource("/log4j.xml").toURI()); |
|---|
| 55 | 54 | |
|---|
| 56 | | - log.debug("SeCuris client tool init "); |
|---|
| 55 | + LOG.debug("SeCuris client tool init "); |
|---|
| 57 | 56 | |
|---|
| 58 | 57 | checkConfigFile(); |
|---|
| 59 | 58 | CommandLine cmd = getCommandLine(args); |
|---|
| .. | .. |
|---|
| 65 | 64 | filename = "./license.req"; |
|---|
| 66 | 65 | File file = new File(filename); |
|---|
| 67 | 66 | LicenseManager.getInstance().createRequestFile(file); |
|---|
| 68 | | - log.info("Request file {} generated OK", file.getAbsolutePath()); |
|---|
| 67 | + LOG.info("Request file {} generated OK", file.getAbsolutePath()); |
|---|
| 69 | 68 | System.exit(0); |
|---|
| 70 | 69 | } |
|---|
| 71 | 70 | |
|---|
| .. | .. |
|---|
| 76 | 75 | File file = new File(filename); |
|---|
| 77 | 76 | try { |
|---|
| 78 | 77 | LicenseManager.getInstance().validateLicense(file); |
|---|
| 79 | | - log.info("License file {} is valid", file.getAbsolutePath()); |
|---|
| 78 | + LOG.info("License file {} is valid", file.getAbsolutePath()); |
|---|
| 80 | 79 | } catch (SeCurisException e) { |
|---|
| 81 | | - log.info("License file {} is NOT valid", file.getAbsolutePath()); |
|---|
| 82 | | - log.info("Reason: {}", e.toString()); |
|---|
| 80 | + LOG.info("License file {} is NOT valid", file.getAbsolutePath()); |
|---|
| 81 | + LOG.info("Reason: {}", e.toString()); |
|---|
| 83 | 82 | } |
|---|
| 84 | 83 | |
|---|
| 85 | 84 | System.exit(0); |
|---|
| .. | .. |
|---|
| 89 | 88 | String reqFilename = cmd.getOptionValue("rfile"); |
|---|
| 90 | 89 | checkMandatoryParameter(reqFilename, "rfile"); |
|---|
| 91 | 90 | |
|---|
| 92 | | - log.warn("This command is not yet implemented"); |
|---|
| 91 | + LOG.warn("This command is not yet implemented"); |
|---|
| 93 | 92 | System.exit(0); |
|---|
| 94 | 93 | } |
|---|
| 95 | 94 | |
|---|
| 96 | 95 | if (cmd.hasOption('t')) { |
|---|
| 97 | | - log.warn("This command is not yet implemented"); |
|---|
| 96 | + LOG.warn("This command is not yet implemented"); |
|---|
| 98 | 97 | System.exit(0); |
|---|
| 99 | 98 | } |
|---|
| 100 | 99 | |
|---|
| 101 | 100 | if (cmd.hasOption('r')) { |
|---|
| 102 | 101 | String licFilename = cmd.getOptionValue("renew"); |
|---|
| 103 | 102 | checkMandatoryParameter(licFilename, "renew"); |
|---|
| 104 | | - log.warn("This command is not yet implemented"); |
|---|
| 103 | + LOG.warn("This command is not yet implemented"); |
|---|
| 105 | 104 | System.exit(0); |
|---|
| 106 | 105 | } |
|---|
| 107 | 106 | |
|---|
| 108 | 107 | } catch (SeCurisException e) { |
|---|
| 109 | | - log.error("The command generated an error: {}", e.toString()); |
|---|
| 108 | + LOG.error("The command generated an error: {}", e.toString()); |
|---|
| 110 | 109 | } |
|---|
| 111 | 110 | } |
|---|
| 112 | 111 | |
|---|
| 113 | 112 | private static void checkMandatoryParameter(String value, String param) { |
|---|
| 114 | 113 | if (value == null) { |
|---|
| 115 | | - log.error("Parameter {} is mandatory. Use --help to get information about parameters", param); |
|---|
| 114 | + LOG.error("Parameter {} is mandatory. Use --help to get information about parameters", param); |
|---|
| 116 | 115 | System.exit(-5); |
|---|
| 117 | 116 | } |
|---|
| 118 | 117 | } |
|---|
| .. | .. |
|---|
| 123 | 122 | private static void checkConfigFile() { |
|---|
| 124 | 123 | String appCode = Params.get(Params.KEYS.APPLICATION_CODE); |
|---|
| 125 | 124 | if (appCode == null) { |
|---|
| 126 | | - log.error("Manadatory parameter {} is not set in config file", Params.KEYS.APPLICATION_CODE); |
|---|
| 125 | + LOG.error("Manadatory parameter {} is not set in config file", Params.KEYS.APPLICATION_CODE); |
|---|
| 127 | 126 | System.exit(-3); |
|---|
| 128 | 127 | } |
|---|
| 129 | 128 | String customerCode = Params.get(Params.KEYS.CUSTOMER_CODE); |
|---|
| 130 | 129 | if (customerCode == null) { |
|---|
| 131 | | - log.error("Manadatory parameter {} is not set in config file", Params.KEYS.CUSTOMER_CODE); |
|---|
| 130 | + LOG.error("Manadatory parameter {} is not set in config file", Params.KEYS.CUSTOMER_CODE); |
|---|
| 132 | 131 | System.exit(-4); |
|---|
| 133 | 132 | } |
|---|
| 134 | 133 | } |
|---|
| .. | .. |
|---|
| 25 | 25 | */ |
|---|
| 26 | 26 | public class LicenseManager { |
|---|
| 27 | 27 | |
|---|
| 28 | | - private static final Logger log = LogManager.getLogger(License.class); |
|---|
| 28 | + private static final Logger LOG = LogManager.getLogger(License.class); |
|---|
| 29 | 29 | |
|---|
| 30 | 30 | private static LicenseManager singleton = new LicenseManager(); |
|---|
| 31 | 31 | |
|---|
| .. | .. |
|---|
| 109 | 109 | json = JsonUtils.toJSON(signedLic, true).getBytes("utf-8"); |
|---|
| 110 | 110 | Files.write(Paths.get(file.toURI()), json, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); |
|---|
| 111 | 111 | } catch (UnsupportedEncodingException e) { |
|---|
| 112 | | - log.error("Error creating json doc from license: " + license, e); |
|---|
| 112 | + LOG.error("Error creating json doc from license: " + license, e); |
|---|
| 113 | 113 | throw new SeCurisException("Error creating json doc from license: " + license, e); |
|---|
| 114 | 114 | } catch (IOException e) { |
|---|
| 115 | | - log.error("Error creating license file: " + file, e); |
|---|
| 115 | + LOG.error("Error creating license file: " + file, e); |
|---|
| 116 | 116 | throw new SeCurisException("Error creating json doc from license: " + license, e); |
|---|
| 117 | 117 | } |
|---|
| 118 | 118 | |
|---|
| 119 | | - log.debug("License saved in {}", file); |
|---|
| 119 | + LOG.debug("License saved in {}", file); |
|---|
| 120 | 120 | |
|---|
| 121 | 121 | } |
|---|
| 122 | 122 | |
|---|
| .. | .. |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | public class LicenseValidator { |
|---|
| 16 | 16 | |
|---|
| 17 | | - private static final Logger log = LogManager.getLogger(LicenseValidator.class); |
|---|
| 17 | + private static final Logger LOG = LogManager.getLogger(LicenseValidator.class); |
|---|
| 18 | 18 | |
|---|
| 19 | 19 | private static LicenseValidator singleton = new LicenseValidator(); |
|---|
| 20 | 20 | protected static byte[] LOGO_SECRET; |
|---|
| .. | .. |
|---|
| 23 | 23 | try { |
|---|
| 24 | 24 | LOGO_SECRET = "Logo ipsum s3cr3t test áíóú".getBytes("utf-8"); |
|---|
| 25 | 25 | } catch (UnsupportedEncodingException e) { |
|---|
| 26 | | - log.error("Unexpected error getting LOGO secret", e); |
|---|
| 26 | + LOG.error("Unexpected error getting LOGO secret", e); |
|---|
| 27 | 27 | } |
|---|
| 28 | 28 | } |
|---|
| 29 | 29 | |
|---|
| .. | .. |
|---|
| 43 | 43 | String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LOGO_SECRET); |
|---|
| 44 | 44 | return shaLogo; |
|---|
| 45 | 45 | } catch (IOException e) { |
|---|
| 46 | | - log.warn("Customer logo was not found in images/logo_customer.png"); |
|---|
| 46 | + LOG.warn("Customer logo was not found in images/logo_customer.png"); |
|---|
| 47 | 47 | return null; |
|---|
| 48 | 48 | } |
|---|
| 49 | 49 | } |
|---|
| 50 | 50 | |
|---|
| 51 | 51 | public void validateLogo(RequestBean reqBean) throws SeCurisException { |
|---|
| 52 | 52 | if (reqBean.getCrcLogo() == null) { |
|---|
| 53 | | - log.info("Customer logo is not included in license file and won't be validated"); |
|---|
| 53 | + LOG.info("Customer logo is not included in license file and won't be validated"); |
|---|
| 54 | 54 | } else { |
|---|
| 55 | 55 | String currentCRC = getCrcLogo(); |
|---|
| 56 | 56 | if (!currentCRC.equals(reqBean.getCrcLogo())) |
|---|
| .. | .. |
|---|
| 19 | 19 | |
|---|
| 20 | 20 | public class ReqGenerator { |
|---|
| 21 | 21 | |
|---|
| 22 | | - private static final Logger log = LogManager.getLogger(ReqGenerator.class); |
|---|
| 22 | + private static final Logger LOG = LogManager.getLogger(ReqGenerator.class); |
|---|
| 23 | 23 | |
|---|
| 24 | 24 | private static ReqGenerator singleton = new ReqGenerator(); |
|---|
| 25 | 25 | |
|---|
| .. | .. |
|---|
| 49 | 49 | RequestBean req = JsonUtils.json2object(json, RequestBean.class); |
|---|
| 50 | 50 | return req; |
|---|
| 51 | 51 | } catch (IOException e) { |
|---|
| 52 | | - log.error("Request file {} was not found or is not accesible"); |
|---|
| 52 | + LOG.error("Request file {} was not found or is not accesible"); |
|---|
| 53 | 53 | throw new SeCurisException("ERROR accesing request file: " + requestFile.getAbsolutePath(), e); |
|---|
| 54 | 54 | } |
|---|
| 55 | 55 | } |
|---|
| .. | .. |
|---|
| 67 | 67 | json = JsonUtils.toJSON(req, true).getBytes("utf-8"); |
|---|
| 68 | 68 | Files.write(Paths.get(file.toURI()), json, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); |
|---|
| 69 | 69 | } catch (UnsupportedEncodingException e) { |
|---|
| 70 | | - log.error("Error creating json doc from request: " + req, e); |
|---|
| 70 | + LOG.error("Error creating json doc from request: " + req, e); |
|---|
| 71 | 71 | throw new SeCurisException("Error creating json doc from request: " + req, e); |
|---|
| 72 | 72 | } catch (IOException e) { |
|---|
| 73 | | - log.error("Error creating request file: " + file, e); |
|---|
| 73 | + LOG.error("Error creating request file: " + file, e); |
|---|
| 74 | 74 | throw new SeCurisException("Error creating request file: " + file, e); |
|---|
| 75 | 75 | } |
|---|
| 76 | 76 | |
|---|
| 77 | | - log.debug("License saved in {}", file); |
|---|
| 77 | + LOG.debug("License saved in {}", file); |
|---|
| 78 | 78 | |
|---|
| 79 | 79 | } |
|---|
| 80 | 80 | |
|---|
| .. | .. |
|---|
| 87 | 87 | String shaLogo = LicUtils.sha256(IOUtils.toByteArray(is), LicenseValidator.LOGO_SECRET); |
|---|
| 88 | 88 | return shaLogo; |
|---|
| 89 | 89 | } catch (IOException e) { |
|---|
| 90 | | - log.error("Customer logo was not found in classpath in " + logResource, e); |
|---|
| 90 | + LOG.error("Customer logo was not found in classpath in " + logResource, e); |
|---|
| 91 | 91 | return null; |
|---|
| 92 | 92 | } |
|---|
| 93 | 93 | } |
|---|
| .. | .. |
|---|
| 21 | 21 | */ |
|---|
| 22 | 22 | public class HWInfo { |
|---|
| 23 | 23 | |
|---|
| 24 | | - private static final Logger log = LogManager.getLogger(HWInfo.class); |
|---|
| 24 | + private static final Logger LOG = LogManager.getLogger(HWInfo.class); |
|---|
| 25 | 25 | |
|---|
| 26 | 26 | public static String getOsName() { |
|---|
| 27 | 27 | return System.getProperty("os.name"); |
|---|
| .. | .. |
|---|
| 47 | 47 | for (NetworkInterface network : Collections.list(NetworkInterface.getNetworkInterfaces())) { |
|---|
| 48 | 48 | if (!network.isLoopback() && !network.isVirtual() && !network.isPointToPoint() && network.getHardwareAddress() != null) { |
|---|
| 49 | 49 | macs.add(network.getHardwareAddress()); |
|---|
| 50 | | - log.debug("Interface added {}, MAC: {}", network.getName(), network.getHardwareAddress()); |
|---|
| 50 | + LOG.debug("Interface added {}, MAC: {}", network.getName(), network.getHardwareAddress()); |
|---|
| 51 | 51 | logInterface(network); |
|---|
| 52 | 52 | } |
|---|
| 53 | 53 | } |
|---|
| .. | .. |
|---|
| 57 | 57 | NetworkInterface network = NetworkInterface.getByInetAddress(InetAddress.getLocalHost()); |
|---|
| 58 | 58 | if (network.getHardwareAddress() != null) |
|---|
| 59 | 59 | macs.add(network.getHardwareAddress()); |
|---|
| 60 | | - log.debug("Selected interface (Inet Address rule)"); |
|---|
| 60 | + LOG.debug("Selected interface (Inet Address rule)"); |
|---|
| 61 | 61 | logInterface(network); |
|---|
| 62 | 62 | } |
|---|
| 63 | 63 | |
|---|
| .. | .. |
|---|
| 67 | 67 | if (!network.isLoopback() && !network.isVirtual() && !network.isPointToPoint() && network.getHardwareAddress() != null) { |
|---|
| 68 | 68 | if (network.getHardwareAddress() != null) |
|---|
| 69 | 69 | macs.add(network.getHardwareAddress()); |
|---|
| 70 | | - log.debug("Selected interface (Any with MAC rule)"); |
|---|
| 70 | + LOG.debug("Selected interface (Any with MAC rule)"); |
|---|
| 71 | 71 | logInterface(network); |
|---|
| 72 | 72 | break; |
|---|
| 73 | 73 | } |
|---|
| .. | .. |
|---|
| 81 | 81 | for (byte[] mac : macs) { |
|---|
| 82 | 82 | macAddresses.add(printMacAddress(mac)); |
|---|
| 83 | 83 | } |
|---|
| 84 | | - log.debug("MAC Addresses: {}", macAddresses); |
|---|
| 84 | + LOG.debug("MAC Addresses: {}", macAddresses); |
|---|
| 85 | 85 | return macAddresses; |
|---|
| 86 | 86 | |
|---|
| 87 | 87 | } catch (UnknownHostException e) { |
|---|
| .. | .. |
|---|
| 103 | 103 | } |
|---|
| 104 | 104 | |
|---|
| 105 | 105 | private static void logInterface(NetworkInterface network) { |
|---|
| 106 | | - log.debug("Interface name: {}", network.getName()); |
|---|
| 107 | | - log.debug("Interface display name: {}", network.getDisplayName()); |
|---|
| 106 | + LOG.debug("Interface name: {}", network.getName()); |
|---|
| 107 | + LOG.debug("Interface display name: {}", network.getDisplayName()); |
|---|
| 108 | 108 | try { |
|---|
| 109 | | - log.debug("Interface mac: {}", printMacAddress(network.getHardwareAddress())); |
|---|
| 109 | + LOG.debug("Interface mac: {}", printMacAddress(network.getHardwareAddress())); |
|---|
| 110 | 110 | } catch (SocketException e) { |
|---|
| 111 | 111 | // Silent |
|---|
| 112 | 112 | } |
|---|
| .. | .. |
|---|
| 22 | 22 | */ |
|---|
| 23 | 23 | public class JsonUtils { |
|---|
| 24 | 24 | |
|---|
| 25 | | - private static final Logger log = LogManager.getLogger(JsonUtils.class); |
|---|
| 25 | + private static final Logger LOG = LogManager.getLogger(JsonUtils.class); |
|---|
| 26 | 26 | |
|---|
| 27 | 27 | final private static ObjectMapper MAPPER = new ObjectMapper(); |
|---|
| 28 | 28 | |
|---|
| .. | .. |
|---|
| 58 | 58 | } |
|---|
| 59 | 59 | return MAPPER.readValue(json, type); |
|---|
| 60 | 60 | } catch (JsonParseException e) { |
|---|
| 61 | | - log.error("Error parsing JSON string to obejct: {}", json, e); |
|---|
| 61 | + LOG.error("Error parsing JSON string to obejct: {}", json, e); |
|---|
| 62 | 62 | if (json.length() > 60) |
|---|
| 63 | 63 | json = json.substring(0, 50) + "..."; |
|---|
| 64 | 64 | throw new SeCurisException("Error parsing JSON string to object: " + json, e); |
|---|
| 65 | 65 | } catch (IOException e) { |
|---|
| 66 | | - log.error("Error parsing JSON string to object: {}", json, e); |
|---|
| 66 | + LOG.error("Error parsing JSON string to object: {}", json, e); |
|---|
| 67 | 67 | if (json.length() > 60) |
|---|
| 68 | 68 | json = json.substring(0, 50) + "..."; |
|---|
| 69 | 69 | throw new SeCurisException("Error parsing JSON string to object: " + json, e); |
|---|
| .. | .. |
|---|
| 85 | 85 | } |
|---|
| 86 | 86 | return MAPPER.writeValueAsString(obj); |
|---|
| 87 | 87 | } catch (JsonProcessingException e) { |
|---|
| 88 | | - log.error("Error formating JSON from object: {}", obj, e); |
|---|
| 88 | + LOG.error("Error formating JSON from object: {}", obj, e); |
|---|
| 89 | 89 | throw new SeCurisException("Error formating JSON from object: " + obj, e); |
|---|
| 90 | 90 | } catch (IOException e) { |
|---|
| 91 | | - log.error("Error formating JSON from object: {}", obj, e); |
|---|
| 91 | + LOG.error("Error formating JSON from object: {}", obj, e); |
|---|
| 92 | 92 | throw new SeCurisException("Error formating JSON from object: " + obj, e); |
|---|
| 93 | 93 | } |
|---|
| 94 | 94 | } |
|---|
| .. | .. |
|---|
| 111 | 111 | MAPPER.disable(SerializationConfig.Feature.INDENT_OUTPUT); |
|---|
| 112 | 112 | return json; |
|---|
| 113 | 113 | } catch (JsonProcessingException e) { |
|---|
| 114 | | - log.error("Error formating JSON from object: {}", obj, e); |
|---|
| 114 | + LOG.error("Error formating JSON from object: {}", obj, e); |
|---|
| 115 | 115 | throw new SeCurisException("Error formating JSON from object: " + obj, e); |
|---|
| 116 | 116 | } catch (IOException e) { |
|---|
| 117 | | - log.error("Error formating JSON from object: {}", obj, e); |
|---|
| 117 | + LOG.error("Error formating JSON from object: {}", obj, e); |
|---|
| 118 | 118 | throw new SeCurisException("Error formating JSON from object: " + obj, e); |
|---|
| 119 | 119 | } |
|---|
| 120 | 120 | } |
|---|
| .. | .. |
|---|
| 137 | 137 | } |
|---|
| 138 | 138 | return MAPPER.readValue(json, Map.class); |
|---|
| 139 | 139 | } catch (JsonParseException e) { |
|---|
| 140 | | - log.error("Error parsing JSON string to map: {}", json, e); |
|---|
| 140 | + LOG.error("Error parsing JSON string to map: {}", json, e); |
|---|
| 141 | 141 | throw e; |
|---|
| 142 | 142 | } catch (IOException e) { |
|---|
| 143 | | - log.error("Error parsing JSON string to map: {}", json, e); |
|---|
| 143 | + LOG.error("Error parsing JSON string to map: {}", json, e); |
|---|
| 144 | 144 | } |
|---|
| 145 | 145 | return null; |
|---|
| 146 | 146 | } |
|---|
| .. | .. |
|---|
| 160 | 160 | } |
|---|
| 161 | 161 | return MAPPER.writeValueAsString(map); |
|---|
| 162 | 162 | } catch (JsonProcessingException e) { |
|---|
| 163 | | - log.error("Error formating JSON from map: {}", map, e); |
|---|
| 163 | + LOG.error("Error formating JSON from map: {}", map, e); |
|---|
| 164 | 164 | } catch (IOException e) { |
|---|
| 165 | | - log.error("Error formating JSON from map: {}", map, e); |
|---|
| 165 | + LOG.error("Error formating JSON from map: {}", map, e); |
|---|
| 166 | 166 | } |
|---|
| 167 | 167 | |
|---|
| 168 | 168 | return null; |
|---|
| .. | .. |
|---|
| 182 | 182 | try { |
|---|
| 183 | 183 | return MAPPER.readValue(json, List.class); |
|---|
| 184 | 184 | } catch (JsonParseException e) { |
|---|
| 185 | | - log.error("Error converting JSON string to object {}", json, e); |
|---|
| 185 | + LOG.error("Error converting JSON string to object {}", json, e); |
|---|
| 186 | 186 | throw new SeCurisException("Error converting JSON to object", e); |
|---|
| 187 | 187 | } catch (IOException e) { |
|---|
| 188 | | - log.error("Error converting JSON string to object {}", json, e); |
|---|
| 188 | + LOG.error("Error converting JSON string to object {}", json, e); |
|---|
| 189 | 189 | throw new SeCurisException("Error converting JSON to object", e); |
|---|
| 190 | 190 | } |
|---|
| 191 | 191 | } |
|---|
| .. | .. |
|---|
| 206 | 206 | } catch (JsonParseException e) { |
|---|
| 207 | 207 | throw new SeCurisException("Error converting JSON to object", e); |
|---|
| 208 | 208 | } catch (IOException e) { |
|---|
| 209 | | - log.error("Error converting JSON to object", e); |
|---|
| 209 | + LOG.error("Error converting JSON to object", e); |
|---|
| 210 | 210 | throw new SeCurisException("Error converting JSON to object", e); |
|---|
| 211 | 211 | } |
|---|
| 212 | 212 | } |
|---|
| .. | .. |
|---|
| 9 | 9 | |
|---|
| 10 | 10 | public class LicUtils { |
|---|
| 11 | 11 | |
|---|
| 12 | | - private static final Logger log = LogManager.getLogger(LicUtils.class); |
|---|
| 12 | + private static final Logger LOG = LogManager.getLogger(LicUtils.class); |
|---|
| 13 | 13 | |
|---|
| 14 | 14 | public static String md5(String str) { |
|---|
| 15 | 15 | try { |
|---|
| .. | .. |
|---|
| 18 | 18 | BigInteger i = new BigInteger(1, mDigest.digest()); |
|---|
| 19 | 19 | return String.format("%1$032x", i); |
|---|
| 20 | 20 | } catch (NoSuchAlgorithmException e) { |
|---|
| 21 | | - log.error("Error generating MD5 for string: " + str, e); |
|---|
| 21 | + LOG.error("Error generating MD5 for string: " + str, e); |
|---|
| 22 | 22 | } |
|---|
| 23 | 23 | return null; |
|---|
| 24 | 24 | } |
|---|
| .. | .. |
|---|
| 34 | 34 | BigInteger i = new BigInteger(1, mDigest.digest()); |
|---|
| 35 | 35 | return String.format("%1$064x", i); |
|---|
| 36 | 36 | } catch (NoSuchAlgorithmException e) { |
|---|
| 37 | | - log.error("Error generating SHA-256 for bytes: " + bytes, e); |
|---|
| 37 | + LOG.error("Error generating SHA-256 for bytes: " + bytes, e); |
|---|
| 38 | 38 | } |
|---|
| 39 | 39 | return null; |
|---|
| 40 | 40 | } |
|---|
| .. | .. |
|---|
| 48 | 48 | BigInteger i = new BigInteger(1, mDigest.digest()); |
|---|
| 49 | 49 | return String.format("%1$064x", i); |
|---|
| 50 | 50 | } catch (NoSuchAlgorithmException e) { |
|---|
| 51 | | - log.error("Error generating SHA-256 for bytes: " + bytes, e); |
|---|
| 51 | + LOG.error("Error generating SHA-256 for bytes: " + bytes, e); |
|---|
| 52 | 52 | } |
|---|
| 53 | 53 | return null; |
|---|
| 54 | 54 | } |
|---|
| .. | .. |
|---|
| 17 | 17 | */ |
|---|
| 18 | 18 | public class Params { |
|---|
| 19 | 19 | |
|---|
| 20 | | - private static Logger log = LogManager.getLogger(Params.class); |
|---|
| 20 | + private static final Logger LOG = LogManager.getLogger(Params.class); |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | /** |
|---|
| 23 | 23 | * Key used to store config file resource location. In a web application, can be set as initial parameter in a servlet loaded on startup |
|---|
| .. | .. |
|---|
| 30 | 30 | try { |
|---|
| 31 | 31 | loadParameters(KEY_CONFIG_FILE); |
|---|
| 32 | 32 | } catch (IOException e) { |
|---|
| 33 | | - log.error("Config file {} was not found in classpath", KEY_CONFIG_FILE); |
|---|
| 33 | + LOG.error("Config file {} was not found in classpath", KEY_CONFIG_FILE); |
|---|
| 34 | 34 | System.exit(-2); |
|---|
| 35 | 35 | } |
|---|
| 36 | 36 | } |
|---|
| .. | .. |
|---|
| 44 | 44 | */ |
|---|
| 45 | 45 | public static void loadParameters(String resource) throws IOException { |
|---|
| 46 | 46 | |
|---|
| 47 | | - log.debug("Loading params from " + resource); |
|---|
| 47 | + LOG.debug("Loading params from " + resource); |
|---|
| 48 | 48 | InputStream fileis = Params.class.getResourceAsStream(resource); |
|---|
| 49 | 49 | |
|---|
| 50 | 50 | params = new Properties(); |
|---|
| 51 | 51 | try { |
|---|
| 52 | 52 | |
|---|
| 53 | 53 | params.load(fileis); |
|---|
| 54 | | - log.debug("Params loaded OK from {}", resource); |
|---|
| 54 | + LOG.debug("Params loaded OK from {}", resource); |
|---|
| 55 | 55 | } catch (IOException e) { |
|---|
| 56 | | - log.error("Error loading config file: " + e); |
|---|
| 56 | + LOG.error("Error loading config file: " + e); |
|---|
| 57 | 57 | params = null; |
|---|
| 58 | 58 | throw e; |
|---|
| 59 | 59 | } |
|---|
| .. | .. |
|---|
| 31 | 31 | */ |
|---|
| 32 | 32 | public class SignatureHelper { |
|---|
| 33 | 33 | |
|---|
| 34 | | - private static final Logger log = LogManager.getLogger(SignatureHelper.class); |
|---|
| 34 | + private static final Logger LOG = LogManager.getLogger(SignatureHelper.class); |
|---|
| 35 | 35 | private static String AUX = "hEDhryRjs2QRE"; |
|---|
| 36 | 36 | |
|---|
| 37 | 37 | private static SignatureHelper singleton = new SignatureHelper(); |
|---|
| .. | .. |
|---|
| 66 | 66 | if (signature.verify(Base64.decodeBase64(licBean.getSignature()))) |
|---|
| 67 | 67 | return; |
|---|
| 68 | 68 | } catch (NoSuchAlgorithmException e) { |
|---|
| 69 | | - log.error("Error validating license for " + licBean, e); |
|---|
| 69 | + LOG.error("Error validating license for " + licBean, e); |
|---|
| 70 | 70 | } catch (InvalidKeyException e) { |
|---|
| 71 | | - log.error("Error validating license for " + licBean, e); |
|---|
| 71 | + LOG.error("Error validating license for " + licBean, e); |
|---|
| 72 | 72 | } catch (InvalidKeySpecException e) { |
|---|
| 73 | | - log.error("Error validating license for " + licBean, e); |
|---|
| 73 | + LOG.error("Error validating license for " + licBean, e); |
|---|
| 74 | 74 | } catch (IOException e) { |
|---|
| 75 | | - log.error("Error validating license for " + licBean, e); |
|---|
| 75 | + LOG.error("Error validating license for " + licBean, e); |
|---|
| 76 | 76 | } catch (SignatureException e) { |
|---|
| 77 | | - log.error("Error validating license for " + licBean, e); |
|---|
| 77 | + LOG.error("Error validating license for " + licBean, e); |
|---|
| 78 | 78 | } |
|---|
| 79 | 79 | throw new SeCurisException("License could not be validated"); |
|---|
| 80 | 80 | |
|---|