Package nl.altindag.ssl.util
Class TrustManagerUtils
- java.lang.Object
-
- nl.altindag.ssl.util.TrustManagerUtils
-
public final class TrustManagerUtils extends Object
- Author:
- Hakan Altindag
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TrustManagerUtils.TrustManagerBuilder
-
Method Summary
-
-
-
Method Detail
-
combine
public static X509ExtendedTrustManager combine(X509TrustManager... trustManagers)
-
combine
public static X509ExtendedTrustManager combine(List<? extends X509TrustManager> trustManagers)
-
toArray
public static <T extends X509TrustManager> X509ExtendedTrustManager[] toArray(T trustManager)
-
createTrustManagerWithJdkTrustedCertificates
public static X509ExtendedTrustManager createTrustManagerWithJdkTrustedCertificates()
-
createTrustManagerWithSystemTrustedCertificates
public static Optional<X509ExtendedTrustManager> createTrustManagerWithSystemTrustedCertificates()
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(List<X509Certificate> certificates)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(KeyStore... trustStores)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(KeyStore trustStore)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(KeyStore trustStore, String trustManagerFactoryAlgorithm)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(KeyStore trustStore, String trustManagerFactoryAlgorithm, String securityProviderName)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(KeyStore trustStore, String trustManagerFactoryAlgorithm, Provider securityProvider)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(KeyStore trustStore, TrustManagerFactory trustManagerFactory)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(ManagerFactoryParameters... managerFactoryParameters)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(ManagerFactoryParameters managerFactoryParameters)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(ManagerFactoryParameters managerFactoryParameters, String trustManagerFactoryAlgorithm)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(ManagerFactoryParameters managerFactoryParameters, String trustManagerFactoryAlgorithm, String securityProviderName)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(ManagerFactoryParameters managerFactoryParameters, String trustManagerFactoryAlgorithm, Provider securityProvider)
-
createTrustManager
public static X509ExtendedTrustManager createTrustManager(ManagerFactoryParameters managerFactoryParameters, TrustManagerFactory trustManagerFactory)
-
createUnsafeTrustManager
public static X509ExtendedTrustManager createUnsafeTrustManager()
-
createDummyTrustManager
public static X509ExtendedTrustManager createDummyTrustManager()
-
createLoggingTrustManager
public static X509ExtendedTrustManager createLoggingTrustManager(X509TrustManager baseTrustManager)
-
createCertificateCapturingTrustManager
public static X509ExtendedTrustManager createCertificateCapturingTrustManager(List<X509Certificate> certificatesCollector)
-
createCertificateCapturingTrustManager
public static X509ExtendedTrustManager createCertificateCapturingTrustManager(X509TrustManager baseTrustManager, List<X509Certificate> certificatesCollector)
-
wrapIfNeeded
public static X509ExtendedTrustManager wrapIfNeeded(X509TrustManager trustManager)
-
createTrustManagerFactory
public static TrustManagerFactory createTrustManagerFactory(TrustManager trustManager)
-
getTrustManager
public static <T extends TrustManagerFactory> X509ExtendedTrustManager getTrustManager(T trustManagerFactory)
-
createInflatableTrustManager
public static X509ExtendedTrustManager createInflatableTrustManager()
-
createInflatableTrustManager
@Deprecated public static X509ExtendedTrustManager createInflatableTrustManager(Path trustStorePath, char[] trustStorePassword, String trustStoreType, BiPredicate<X509Certificate[],String> certificateAndAuthTypeTrustPredicate)
Deprecated.
-
createInflatableTrustManager
public static X509ExtendedTrustManager createInflatableTrustManager(Path trustStorePath, char[] trustStorePassword, String trustStoreType, Predicate<TrustManagerParameters> trustManagerParametersPredicate)
-
addCertificate
public static void addCertificate(X509ExtendedTrustManager trustManager, X509Certificate certificate)
Adds a new to be trusted certificate to the existing TrustManager. The provided TrustManager should be an instance ofInflatableX509ExtendedTrustManager
and it is allowed that it is wrapped in aCompositeX509ExtendedTrustManager
-
addCertificate
public static void addCertificate(X509ExtendedTrustManager trustManager, List<X509Certificate> certificates)
Adds a new to be trusted certificate to the existing TrustManager. The provided TrustManager should be an instance ofInflatableX509ExtendedTrustManager
and it is allowed that it is wrapped in aCompositeX509ExtendedTrustManager
-
createSwappableTrustManager
public static X509ExtendedTrustManager createSwappableTrustManager(X509TrustManager trustManager)
Wraps the given TrustManager into an instance of a Hot Swappable TrustManager. This type of TrustManager has the capability of swapping in and out different TrustManagers at runtime.- Parameters:
trustManager
- To be wrapped TrustManager- Returns:
- Swappable TrustManager
-
swapTrustManager
public static void swapTrustManager(X509TrustManager baseTrustManager, X509TrustManager newTrustManager)
Swaps the internal TrustManager instance with the given trustManager object. The baseTrustManager should be an instance ofHotSwappableX509ExtendedTrustManager
and can be created withcreateSwappableTrustManager(X509TrustManager)
- Parameters:
baseTrustManager
- an instance ofHotSwappableX509ExtendedTrustManager
newTrustManager
- to be injected instance of a TrustManager- Throws:
GenericTrustManagerException
- ifbaseTrustManager
is not instance ofHotSwappableX509ExtendedTrustManager
-
createEnhanceableTrustManager
@Deprecated public static X509ExtendedTrustManager createEnhanceableTrustManager(X509ExtendedTrustManager trustManager, ChainAndAuthTypeValidator chainAndAuthTypeValidator, ChainAndAuthTypeWithSocketValidator chainAndAuthTypeWithSocketValidator, ChainAndAuthTypeWithSSLEngineValidator chainAndAuthTypeWithSSLEngineValidator)
Deprecated.
-
createEnhanceableTrustManager
public static X509ExtendedTrustManager createEnhanceableTrustManager(X509ExtendedTrustManager trustManager, Predicate<TrustManagerParameters> trustManagerParametersValidator)
-
trustManagerBuilder
public static TrustManagerUtils.TrustManagerBuilder trustManagerBuilder()
-
-