Package com.codedx.security
Class CompositeX509TrustManager
- java.lang.Object
-
- com.codedx.security.CompositeX509TrustManager
-
- All Implemented Interfaces:
TrustManager
,X509TrustManager
public class CompositeX509TrustManager extends Object implements X509TrustManager
Represents an ordered list ofX509TrustManager
s with additive trust. If any one of the composed managers trusts a certificate chain, then it is trusted by the composite manager. This is necessary because of the fine-print onSSLContext.init(javax.net.ssl.KeyManager[], javax.net.ssl.TrustManager[], java.security.SecureRandom)
: Only the first instance of a particular key and/or trust manager implementation type in the array is used. (For example, only the first javax.net.ssl.X509KeyManager in the array will be used.) see StackOverflow- Since:
- 4/22/2013
- Author:
- codyaray
-
-
Constructor Summary
Constructors Constructor Description CompositeX509TrustManager(List<X509TrustManager> trustManagers)
Initializes the composite trust manager, copying all of the non-null entries in the giventrustManagers
list into its own internal list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkClientTrusted(X509Certificate[] chain, String authType)
void
checkServerTrusted(X509Certificate[] chain, String authType)
X509Certificate[]
getAcceptedIssuers()
-
-
-
Constructor Detail
-
CompositeX509TrustManager
public CompositeX509TrustManager(List<X509TrustManager> trustManagers)
Initializes the composite trust manager, copying all of the non-null entries in the giventrustManagers
list into its own internal list.- Parameters:
trustManagers
- A list of (potentially null) trust managers.
-
-
Method Detail
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException
- Specified by:
checkClientTrusted
in interfaceX509TrustManager
- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException
- Specified by:
checkServerTrusted
in interfaceX509TrustManager
- Throws:
CertificateException
-
getAcceptedIssuers
public X509Certificate[] getAcceptedIssuers()
- Specified by:
getAcceptedIssuers
in interfaceX509TrustManager
-
-