// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.tls;

import org.bouncycastle.jce.provider.BouncyCastleProvider;

import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.KeyStoreException;

/**
 * @author bjorncs
 */
public enum KeyStoreType {
    JKS {
        KeyStore createKeystore() throws KeyStoreException {
            return KeyStore.getInstance("JKS");
        }
    },
    PKCS12 {
        private final BouncyCastleProvider bouncyCastleProvider = new BouncyCastleProvider();

        KeyStore createKeystore() throws KeyStoreException {
            return KeyStore.getInstance("PKCS12", bouncyCastleProvider);
        }
    };
    abstract KeyStore createKeystore() throws GeneralSecurityException;
}

@@ -535,103 +535,8 @@
 2 %7B%0A
-        private final BouncyCastleProvider bouncyCastleProvider = new BouncyCastleProvider();%0A%0A
     
@@ -642,17 +642,17 @@
 KCS12%22, 
-b
+B
 ouncyCas
@@ -662,16 +662,36 @@
 Provider
+Holder.getInstance()
 );%0A     

Use BouncyCastleProviderHolder