public class KeyStoreUtils extends Object
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
logger |
static String |
SUN_PROVIDER_NAME |
Constructor and Description |
---|
KeyStoreUtils() |
Modifier and Type | Method and Description |
---|---|
static KeyManagerFactory |
getKeyManagerFactoryFromKeyStore(KeyStore keyStore,
char[] keystorePassword,
char[] keyPassword)
Returns the
KeyManagerFactory from the provided KeyStore object, initialized with the key or keystore password. |
static KeyStore |
getKeyStore(String keyStoreType)
Returns an empty KeyStore backed by the appropriate provider
|
static String |
getKeyStoreProvider(String keyStoreType)
Returns the provider that will be used for the given keyStoreType
|
static TrustManagerFactory |
getTrustManagerFactoryFromTrustStore(KeyStore trustStore)
Returns the
TrustManagerFactory from the provided KeyStore object, initialized. |
static KeyStore |
getTrustStore(String trustStoreType)
Returns an empty KeyStore intended for use as a TrustStore backed by the appropriate provider
|
static boolean |
isKeyPasswordCorrect(URL keystore,
KeystoreType keystoreType,
char[] password,
char[] keyPassword)
Returns true if the given keystore can be loaded using the given keystore type and password and the default
(first) alias can be retrieved with the key-specific password.
|
static boolean |
isStoreValid(URL keystore,
KeystoreType keystoreType,
char[] password)
Returns true if the given keystore can be loaded using the given keystore type and password.
|
static KeyManagerFactory |
loadKeyManagerFactory(String keystorePath,
String keystorePassword,
String keyPassword,
String keystoreType)
Returns the initialized
KeyManagerFactory . |
static KeyManagerFactory |
loadKeyManagerFactory(TlsConfiguration tlsConfiguration)
Returns the intialized
KeyManagerFactory . |
static KeyStore |
loadKeyStore(String keystorePath,
char[] keystorePassword,
String keystoreType)
Returns a loaded
KeyStore given the provided configuration values. |
static TrustManagerFactory |
loadTrustManagerFactory(String truststorePath,
String truststorePassword,
String truststoreType)
Returns the initialized
TrustManagerFactory . |
static TrustManagerFactory |
loadTrustManagerFactory(TlsConfiguration tlsConfiguration)
Returns the intialized
TrustManagerFactory . |
static KeyStore |
loadTrustStore(String truststorePath,
char[] truststorePassword,
String truststoreType)
Returns a loaded
KeyStore (acting as a truststore) given the provided configuration values. |
static String |
sslContextToString(SSLContext sslContext) |
static String |
sslParametersToString(SSLParameters sslParameters) |
static String |
sslServerSocketToString(SSLServerSocket sslServerSocket) |
private static final org.slf4j.Logger logger
public static final String SUN_PROVIDER_NAME
public static String getKeyStoreProvider(String keyStoreType)
keyStoreType
- the keyStoreTypepublic static KeyStore getKeyStore(String keyStoreType) throws KeyStoreException
keyStoreType
- the keyStoreTypeKeyStoreException
- if a KeyStore of the given type cannot be instantiatedpublic static KeyStore getTrustStore(String trustStoreType) throws KeyStoreException
trustStoreType
- the trustStoreTypeKeyStoreException
- if a KeyStore of the given type cannot be instantiatedpublic static KeyStore loadKeyStore(String keystorePath, char[] keystorePassword, String keystoreType) throws TlsException
KeyStore
given the provided configuration values.keystorePath
- the file path to the keystorekeystorePassword
- the keystore passwordkeystoreType
- the keystore type (JKS
or PKCS12
)TlsException
- if there is a problem loading the keystorepublic static KeyManagerFactory getKeyManagerFactoryFromKeyStore(KeyStore keyStore, char[] keystorePassword, char[] keyPassword) throws TlsException
KeyManagerFactory
from the provided KeyStore
object, initialized with the key or keystore password.keyStore
- the loaded keystorekeystorePassword
- the keystore passwordkeyPassword
- the key passwordTlsException
- if there is a problem initializing or reading from the keystorepublic static KeyManagerFactory loadKeyManagerFactory(TlsConfiguration tlsConfiguration) throws TlsException
KeyManagerFactory
.tlsConfiguration
- the TLS configurationTlsException
- if there is a problem initializing or reading from the keystorepublic static KeyManagerFactory loadKeyManagerFactory(String keystorePath, String keystorePassword, String keyPassword, String keystoreType) throws TlsException
KeyManagerFactory
.keystorePath
- the file path to the keystorekeystorePassword
- the keystore passwordkeyPassword
- the key passwordkeystoreType
- the keystore type (JKS
or PKCS12
)TlsException
- if there is a problem initializing or reading from the keystorepublic static KeyStore loadTrustStore(String truststorePath, char[] truststorePassword, String truststoreType) throws TlsException
KeyStore
(acting as a truststore) given the provided configuration values.truststorePath
- the file path to the truststoretruststorePassword
- the truststore passwordtruststoreType
- the truststore type (JKS
or PKCS12
)TlsException
- if there is a problem loading the truststorepublic static TrustManagerFactory getTrustManagerFactoryFromTrustStore(KeyStore trustStore) throws TlsException
TrustManagerFactory
from the provided KeyStore
object, initialized.trustStore
- the loaded truststoreTlsException
- if there is a problem initializing or reading from the truststorepublic static TrustManagerFactory loadTrustManagerFactory(TlsConfiguration tlsConfiguration) throws TlsException
TrustManagerFactory
.tlsConfiguration
- the TLS configurationTlsException
- if there is a problem initializing or reading from the truststorepublic static TrustManagerFactory loadTrustManagerFactory(String truststorePath, String truststorePassword, String truststoreType) throws TlsException
TrustManagerFactory
.truststorePath
- the file path to the truststoretruststorePassword
- the truststore passwordtruststoreType
- the truststore type (JKS
or PKCS12
)TlsException
- if there is a problem initializing or reading from the truststorepublic static boolean isStoreValid(URL keystore, KeystoreType keystoreType, char[] password)
keystore
- the keystore to validatekeystoreType
- the type of the keystorepassword
- the password to access the keystorepublic static boolean isKeyPasswordCorrect(URL keystore, KeystoreType keystoreType, char[] password, char[] keyPassword)
keystore
- the keystore to validatekeystoreType
- the type of the keystorepassword
- the password to access the keystorekeyPassword
- the password to access the specific keypublic static String sslContextToString(SSLContext sslContext)
public static String sslParametersToString(SSLParameters sslParameters)
public static String sslServerSocketToString(SSLServerSocket sslServerSocket)
Copyright © 2020 Apache NiFi Project. All rights reserved.