Package org.ldaptive.ssl
Class AggregateTrustManager
- java.lang.Object
-
- javax.net.ssl.X509ExtendedTrustManager
-
- org.ldaptive.ssl.AggregateTrustManager
-
- All Implemented Interfaces:
TrustManager
,X509TrustManager
public class AggregateTrustManager extends X509ExtendedTrustManager
Trust manager that delegates to multiple trust managers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AggregateTrustManager.Strategy
Enum to define how trust managers should be processed.private static interface
AggregateTrustManager.TrustManagerConsumer
Interface for consuming a trust manager.
-
Field Summary
Fields Modifier and Type Field Description protected Logger
logger
Logger for this class.private X509ExtendedTrustManager[]
trustManagers
Trust managers to invoke.private AggregateTrustManager.Strategy
trustStrategy
Whether to require all trust managers succeed.
-
Constructor Summary
Constructors Constructor Description AggregateTrustManager(X509TrustManager... managers)
Creates a new aggregate trust manager with the ALLAggregateTrustManager.Strategy
.AggregateTrustManager(AggregateTrustManager.Strategy strategy, X509TrustManager... managers)
Creates a new aggregate trust manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkClientTrusted(X509Certificate[] chain, String authType)
void
checkClientTrusted(X509Certificate[] chain, String authType, Socket socket)
void
checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine)
void
checkServerTrusted(X509Certificate[] chain, String authType)
void
checkServerTrusted(X509Certificate[] chain, String authType, Socket socket)
void
checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine)
X509Certificate[]
getAcceptedIssuers()
X509TrustManager[]
getTrustManagers()
Returns the trust managers that are aggregated.AggregateTrustManager.Strategy
getTrustStrategy()
Returns the trust strategy.String
toString()
private void
trustManagerCheck(AggregateTrustManager.TrustManagerConsumer consumer)
Invoke the supplied consumer for each trust manager.
-
-
-
Field Detail
-
logger
protected final Logger logger
Logger for this class.
-
trustManagers
private final X509ExtendedTrustManager[] trustManagers
Trust managers to invoke.
-
trustStrategy
private final AggregateTrustManager.Strategy trustStrategy
Whether to require all trust managers succeed.
-
-
Constructor Detail
-
AggregateTrustManager
public AggregateTrustManager(X509TrustManager... managers)
Creates a new aggregate trust manager with the ALLAggregateTrustManager.Strategy
.- Parameters:
managers
- to aggregate
-
AggregateTrustManager
public AggregateTrustManager(AggregateTrustManager.Strategy strategy, X509TrustManager... managers)
Creates a new aggregate trust manager.- Parameters:
strategy
- for processing trust managersmanagers
- to aggregate
-
-
Method Detail
-
getTrustManagers
public X509TrustManager[] getTrustManagers()
Returns the trust managers that are aggregated.- Returns:
- trust managers
-
getTrustStrategy
public AggregateTrustManager.Strategy getTrustStrategy()
Returns the trust strategy.- Returns:
- trust strategy
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException
- Specified by:
checkClientTrusted
in classX509ExtendedTrustManager
- Throws:
CertificateException
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException
- Specified by:
checkClientTrusted
in classX509ExtendedTrustManager
- Throws:
CertificateException
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException
- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException
- Specified by:
checkServerTrusted
in classX509ExtendedTrustManager
- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException
- Specified by:
checkServerTrusted
in classX509ExtendedTrustManager
- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException
- Throws:
CertificateException
-
getAcceptedIssuers
public X509Certificate[] getAcceptedIssuers()
-
trustManagerCheck
private void trustManagerCheck(AggregateTrustManager.TrustManagerConsumer consumer) throws CertificateException
Invoke the supplied consumer for each trust manager.- Parameters:
consumer
- to invoke- Throws:
CertificateException
- if trust check fails. For multiple failures the first exception is thrown
-
-