From c9639b32eeefdc1ec028bcbfc6ca2e8474042eb1 Mon Sep 17 00:00:00 2001 From: Michal Banka Date: Fri, 28 Feb 2020 16:49:52 +0100 Subject: Fixed sonar issues in Factory class Signed-off-by: Michal Banka Change-Id: Idde6d2d79d13d25427a8d3e516945e2fb3a7bafa Issue-ID: AAF-997 --- .../aaf/certservice/cmpv2client/external/Factory.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'certService/src/main') diff --git a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Factory.java b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Factory.java index 7072abfd..e570f9ab 100644 --- a/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Factory.java +++ b/certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Factory.java @@ -1,4 +1,4 @@ -/** +/* * ============LICENSE_START==================================================== * org.onap.aaf * =========================================================================== @@ -22,6 +22,9 @@ */ package org.onap.aaf.certservice.cmpv2client.external; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; @@ -29,25 +32,27 @@ import java.security.SecureRandom; public class Factory { + private static final Logger LOGGER = LoggerFactory.getLogger(Factory.class); private static final KeyPairGenerator keygen; private static final SecureRandom random; - private static final String KEY_ALGO = "RSA"; + private static final String KEY_ALGORITHM = "RSA"; private static final int KEY_LENGTH = 2048; - private static final int SUB = 0x08; static { random = new SecureRandom(); KeyPairGenerator tempKeygen; try { - tempKeygen = KeyPairGenerator.getInstance(KEY_ALGO); // ,"BC"); + tempKeygen = KeyPairGenerator.getInstance(KEY_ALGORITHM); tempKeygen.initialize(KEY_LENGTH, random); } catch (NoSuchAlgorithmException e) { tempKeygen = null; - e.printStackTrace(System.err); + LOGGER.error("Given KEY_ALGORITHM is invalid.", e); } keygen = tempKeygen; } + private Factory() { } + public static KeyPair generateKeyPair() { return keygen.generateKeyPair(); } -- cgit 1.2.3-korg