public class SecurityUtility extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
BC |
static String |
BC_FIPS |
static String |
BC_FIPS_PROVIDER_CLASS |
static String |
BC_NON_FIPS_PROVIDER_CLASS |
static Provider |
BC_PROVIDER |
static Provider |
CONSCRYPT_PROVIDER |
static String |
CONSCRYPT_PROVIDER_CLASS |
| Constructor and Description |
|---|
SecurityUtility() |
| Modifier and Type | Method and Description |
|---|---|
static io.netty.handler.ssl.SslContext |
createAutoRefreshSslContextForClient(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
String trustCertsFilePath,
String certFilePath,
String keyFilePath,
String sslContextAlgorithm,
int refreshDurationSec,
ScheduledExecutorService executor)
Creates
SslContext with capability to do auto-cert refresh. |
static io.netty.handler.ssl.SslContext |
createNettySslContextForClient(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
InputStream trustCertsStream,
Certificate[] certificates,
PrivateKey privateKey,
Set<String> ciphers,
Set<String> protocols) |
static io.netty.handler.ssl.SslContext |
createNettySslContextForClient(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
String trustCertsFilePath,
Certificate[] certificates,
PrivateKey privateKey,
Set<String> ciphers,
Set<String> protocols) |
static io.netty.handler.ssl.SslContext |
createNettySslContextForClient(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
String trustCertsFilePath,
Set<String> ciphers,
Set<String> protocols) |
static io.netty.handler.ssl.SslContext |
createNettySslContextForClient(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
String trustCertsFilePath,
String certFilePath,
String keyFilePath,
Set<String> ciphers,
Set<String> protocols) |
static io.netty.handler.ssl.SslContext |
createNettySslContextForServer(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
String trustCertsFilePath,
String certFilePath,
String keyFilePath,
Set<String> ciphers,
Set<String> protocols,
boolean requireTrustedClientCertOnConnect) |
static SSLContext |
createSslContext(boolean allowInsecureConnection,
Certificate[] trustCertficates,
Certificate[] certificates,
PrivateKey privateKey) |
static SSLContext |
createSslContext(boolean allowInsecureConnection,
Certificate[] trustCertficates,
Certificate[] certificates,
PrivateKey privateKey,
String providerName) |
static SSLContext |
createSslContext(boolean allowInsecureConnection,
Certificate[] trustCertificates,
String providerName) |
static SSLContext |
createSslContext(boolean allowInsecureConnection,
String trustCertsFilePath,
String certFilePath,
String keyFilePath,
String providerName) |
static Provider |
getBCProviderFromClassPath()
Get Bouncy Castle provider from classpath, and call Security.addProvider.
|
static Provider |
getProvider()
Get Bouncy Castle provider, and call Security.addProvider(provider) if success.
|
static boolean |
isBCFIPS() |
static X509Certificate[] |
loadCertificatesFromPemFile(String certFilePath) |
static X509Certificate[] |
loadCertificatesFromPemStream(InputStream inStream) |
static PrivateKey |
loadPrivateKeyFromPemFile(String keyFilePath) |
static PrivateKey |
loadPrivateKeyFromPemStream(InputStream inStream) |
static TrustManager[] |
processConscryptTrustManagers(TrustManager[] trustManagers)
Conscrypt TrustManager instances will be configured to use the Pulsar
TlsHostnameVerifier
class. |
static Provider |
resolveProvider(String providerName) |
public static final Provider BC_PROVIDER
public static final String BC_FIPS_PROVIDER_CLASS
public static final String BC_NON_FIPS_PROVIDER_CLASS
public static final String CONSCRYPT_PROVIDER_CLASS
public static final Provider CONSCRYPT_PROVIDER
public static final String BC_FIPS
public static final String BC
public static boolean isBCFIPS()
public static Provider getProvider()
public static Provider getBCProviderFromClassPath() throws Exception
Exceptionpublic static SSLContext createSslContext(boolean allowInsecureConnection, Certificate[] trustCertificates, String providerName) throws GeneralSecurityException
GeneralSecurityExceptionpublic static io.netty.handler.ssl.SslContext createNettySslContextForClient(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
String trustCertsFilePath,
Set<String> ciphers,
Set<String> protocols)
throws GeneralSecurityException,
SSLException,
FileNotFoundException,
IOException
public static SSLContext createSslContext(boolean allowInsecureConnection, String trustCertsFilePath, String certFilePath, String keyFilePath, String providerName) throws GeneralSecurityException
GeneralSecurityExceptionpublic static io.netty.handler.ssl.SslContext createAutoRefreshSslContextForClient(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
String trustCertsFilePath,
String certFilePath,
String keyFilePath,
String sslContextAlgorithm,
int refreshDurationSec,
ScheduledExecutorService executor)
throws GeneralSecurityException,
SSLException,
FileNotFoundException,
IOException
SslContext with capability to do auto-cert refresh.allowInsecureConnection - trustCertsFilePath - certFilePath - keyFilePath - sslContextAlgorithm - refreshDurationSec - executor - GeneralSecurityExceptionSSLExceptionFileNotFoundExceptionIOExceptionpublic static io.netty.handler.ssl.SslContext createNettySslContextForClient(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
String trustCertsFilePath,
String certFilePath,
String keyFilePath,
Set<String> ciphers,
Set<String> protocols)
throws GeneralSecurityException,
SSLException,
FileNotFoundException,
IOException
public static io.netty.handler.ssl.SslContext createNettySslContextForClient(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
String trustCertsFilePath,
Certificate[] certificates,
PrivateKey privateKey,
Set<String> ciphers,
Set<String> protocols)
throws GeneralSecurityException,
SSLException,
FileNotFoundException,
IOException
public static io.netty.handler.ssl.SslContext createNettySslContextForClient(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
InputStream trustCertsStream,
Certificate[] certificates,
PrivateKey privateKey,
Set<String> ciphers,
Set<String> protocols)
throws GeneralSecurityException,
SSLException,
FileNotFoundException,
IOException
public static io.netty.handler.ssl.SslContext createNettySslContextForServer(io.netty.handler.ssl.SslProvider sslProvider,
boolean allowInsecureConnection,
String trustCertsFilePath,
String certFilePath,
String keyFilePath,
Set<String> ciphers,
Set<String> protocols,
boolean requireTrustedClientCertOnConnect)
throws GeneralSecurityException,
SSLException,
FileNotFoundException,
IOException
public static SSLContext createSslContext(boolean allowInsecureConnection, Certificate[] trustCertficates, Certificate[] certificates, PrivateKey privateKey) throws GeneralSecurityException
GeneralSecurityExceptionpublic static SSLContext createSslContext(boolean allowInsecureConnection, Certificate[] trustCertficates, Certificate[] certificates, PrivateKey privateKey, String providerName) throws GeneralSecurityException
GeneralSecurityException@InterfaceAudience.Private public static TrustManager[] processConscryptTrustManagers(TrustManager[] trustManagers)
TlsHostnameVerifier
class.
This method is used as a workaround for https://github.com/google/conscrypt/issues/1015
when Conscrypt / OpenSSL is used as the TLS security provider.trustManagers - the array of TrustManager instances to process.public static X509Certificate[] loadCertificatesFromPemFile(String certFilePath) throws KeyManagementException
KeyManagementExceptionpublic static X509Certificate[] loadCertificatesFromPemStream(InputStream inStream) throws KeyManagementException
KeyManagementExceptionpublic static PrivateKey loadPrivateKeyFromPemFile(String keyFilePath) throws KeyManagementException
KeyManagementExceptionpublic static PrivateKey loadPrivateKeyFromPemStream(InputStream inStream) throws KeyManagementException
KeyManagementExceptionpublic static Provider resolveProvider(String providerName) throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionCopyright © 2017–2022 Apache Software Foundation. All rights reserved.