类 SecurityUtility
java.lang.Object
org.apache.pulsar.common.util.SecurityUtility
Helper class for the security domain.
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static voidconfigureSSLHandler(io.netty.handler.ssl.SslHandler handler) static io.netty.handler.ssl.SslContextcreateAutoRefreshSslContextForClient(io.netty.handler.ssl.SslProvider sslProvider, boolean allowInsecureConnection, String trustCertsFilePath, String certFilePath, String keyFilePath, String sslContextAlgorithm, int refreshDurationSec, ScheduledExecutorService executor) CreatesSslContextwith capability to do auto-cert refresh.static io.netty.handler.ssl.SslContextcreateNettySslContextForClient(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.SslContextcreateNettySslContextForClient(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.SslContextcreateNettySslContextForClient(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.SslContextcreateNettySslContextForClient(io.netty.handler.ssl.SslProvider sslProvider, boolean allowInsecureConnection, String trustCertsFilePath, Set<String> ciphers, Set<String> protocols) static io.netty.handler.ssl.SslContextcreateNettySslContextForServer(io.netty.handler.ssl.SslProvider sslProvider, boolean allowInsecureConnection, String trustCertsFilePath, String certFilePath, String keyFilePath, Set<String> ciphers, Set<String> protocols, boolean requireTrustedClientCertOnConnect) static SSLContextcreateSslContext(boolean allowInsecureConnection, String trustCertsFilePath, String certFilePath, String keyFilePath, String providerName) static SSLContextcreateSslContext(boolean allowInsecureConnection, Certificate[] trustCertificates, String providerName) static SSLContextcreateSslContext(boolean allowInsecureConnection, Certificate[] trustCertficates, Certificate[] certificates, PrivateKey privateKey) static SSLContextcreateSslContext(boolean allowInsecureConnection, Certificate[] trustCertficates, Certificate[] certificates, PrivateKey privateKey, String providerName) static ProviderGet Bouncy Castle provider from classpath, and call Security.addProvider.static ProviderGet Bouncy Castle provider, and call Security.addProvider(provider) if success. 1. try get from classpath. 2. try get from Nar.static booleanisBCFIPS()static X509Certificate[]loadCertificatesFromPemFile(String certFilePath) static X509Certificate[]loadCertificatesFromPemStream(InputStream inStream) static PrivateKeyloadPrivateKeyFromPemFile(String keyFilePath) static PrivateKeyloadPrivateKeyFromPemStream(InputStream inStream) static TrustManager[]processConscryptTrustManagers(TrustManager[] trustManagers) Conscrypt TrustManager instances will be configured to use the PulsarTlsHostnameVerifierclass.static ProviderresolveProvider(String providerName)
-
字段详细资料
-
构造器详细资料
-
SecurityUtility
public SecurityUtility()
-
-
方法详细资料
-
isBCFIPS
public static boolean isBCFIPS() -
getProvider
Get Bouncy Castle provider, and call Security.addProvider(provider) if success. 1. try get from classpath. 2. try get from Nar. -
getBCProviderFromClassPath
Get Bouncy Castle provider from classpath, and call Security.addProvider. Throw Exception if failed.- 抛出:
Exception
-
createSslContext
public static SSLContext createSslContext(boolean allowInsecureConnection, Certificate[] trustCertificates, String providerName) throws GeneralSecurityException -
createNettySslContextForClient
public 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 -
createSslContext
public static SSLContext createSslContext(boolean allowInsecureConnection, String trustCertsFilePath, String certFilePath, String keyFilePath, String providerName) throws GeneralSecurityException -
createAutoRefreshSslContextForClient
public 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 CreatesSslContextwith capability to do auto-cert refresh.- 参数:
allowInsecureConnection-trustCertsFilePath-certFilePath-keyFilePath-sslContextAlgorithm-refreshDurationSec-executor-- 返回:
- 抛出:
GeneralSecurityExceptionSSLExceptionFileNotFoundExceptionIOException
-
createNettySslContextForClient
public 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 -
createNettySslContextForClient
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 -
createNettySslContextForClient
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 -
createNettySslContextForServer
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 -
createSslContext
public static SSLContext createSslContext(boolean allowInsecureConnection, Certificate[] trustCertficates, Certificate[] certificates, PrivateKey privateKey) throws GeneralSecurityException -
createSslContext
public static SSLContext createSslContext(boolean allowInsecureConnection, Certificate[] trustCertficates, Certificate[] certificates, PrivateKey privateKey, String providerName) throws GeneralSecurityException -
processConscryptTrustManagers
Conscrypt TrustManager instances will be configured to use the PulsarTlsHostnameVerifierclass. 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.- 返回:
- same instance passed as parameter
-
loadCertificatesFromPemFile
public static X509Certificate[] loadCertificatesFromPemFile(String certFilePath) throws KeyManagementException -
loadCertificatesFromPemStream
public static X509Certificate[] loadCertificatesFromPemStream(InputStream inStream) throws KeyManagementException -
loadPrivateKeyFromPemFile
public static PrivateKey loadPrivateKeyFromPemFile(String keyFilePath) throws KeyManagementException -
loadPrivateKeyFromPemStream
public static PrivateKey loadPrivateKeyFromPemStream(InputStream inStream) throws KeyManagementException -
configureSSLHandler
public static void configureSSLHandler(io.netty.handler.ssl.SslHandler handler) -
resolveProvider
-