diff options
author | 2020-03-12 06:58:26 +0000 | |
---|---|---|
committer | 2020-03-12 06:58:26 +0000 | |
commit | 366888086655dc0b208b7fd00ab630f046cd90aa (patch) | |
tree | 6b0547cae2b871bf37485ce8b2a7c0b6ae58d8fd /certService/src/main | |
parent | 3310d5240df5cfe07f1a9c3b312fa1d5f8f1238b (diff) | |
parent | c9639b32eeefdc1ec028bcbfc6ca2e8474042eb1 (diff) |
Merge "Fixed sonar issues in Factory class"
Diffstat (limited to 'certService/src/main')
-rw-r--r-- | certService/src/main/java/org/onap/aaf/certservice/cmpv2client/external/Factory.java | 15 |
1 files changed, 10 insertions, 5 deletions
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(); } |