Class CertificateCapturingTrustManager
- java.lang.Object
-
- de.xima.fc.certificate.provider.internal.CertificateCapturingTrustManager
-
- All Implemented Interfaces:
TrustManager,X509TrustManager
public class CertificateCapturingTrustManager extends Object implements X509TrustManager
A TrustManager that captures the certificate chain presented during trust validation.This class delegates trust checks to a provided
X509TrustManagerand records the certificate chain for later inspection. It also tracks whether the validation passed and any exception that occurred during validation.The captured certificates are available as a
ListviagetCapturedServerCertificates().- Since:
- 8.5.0
- Author:
- tobias
-
-
Constructor Summary
Constructors Constructor Description CertificateCapturingTrustManager(X509TrustManager trustManager)Constructs a new CertificateCapturingTrustManager with the given trust manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckClientTrusted(X509Certificate[] chain, String authType)Captures the client certificate chain and delegates trust validation.voidcheckServerTrusted(X509Certificate[] chain, String authType)Captures the server certificate chain and delegates trust validation.X509Certificate[]getAcceptedIssuers()Returns the list of accepted issuers from the underlying trust manager.X509Certificate[]getCapturedClientCertificates()The most recently captured client certificate chain as a list.X509Certificate[]getCapturedServerCertificates()The most recently captured server certificate chain as a list.CertificateExceptiongetClientTrustValidationException()The exception thrown during the last client trust validation, if any.BooleangetClientTrustValidationPassed()Indicates whether the last client trust validation passed.TrustValidationResultgetLastClientTrustValidationResult()Returns the last client trust validation result, including captured certificates and validation status.TrustValidationResultgetLastServerTrustValidationResult()Returns the last server trust validation result, including captured certificates and validation status.CertificateExceptiongetServerTrustValidationException()The exception thrown during the last server trust validation, if any.BooleangetServerTrustValidationPassed()Indicates whether the last server trust validation passed.
-
-
-
Constructor Detail
-
CertificateCapturingTrustManager
public CertificateCapturingTrustManager(X509TrustManager trustManager)
Constructs a new CertificateCapturingTrustManager with the given trust manager.- Parameters:
trustManager- the trust manager to delegate to
-
-
Method Detail
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException
Captures the client certificate chain and delegates trust validation.- Specified by:
checkClientTrustedin interfaceX509TrustManager- Parameters:
chain- the client certificate chainauthType- the authentication type- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException
Captures the server certificate chain and delegates trust validation. Does not rethrow the exception to allow certificate capture.- Specified by:
checkServerTrustedin interfaceX509TrustManager- Parameters:
chain- the server certificate chainauthType- the authentication type- Throws:
CertificateException
-
getAcceptedIssuers
public X509Certificate[] getAcceptedIssuers()
Returns the list of accepted issuers from the underlying trust manager.- Specified by:
getAcceptedIssuersin interfaceX509TrustManager- Returns:
- an array of accepted X509Certificate issuers
-
getLastClientTrustValidationResult
public TrustValidationResult getLastClientTrustValidationResult()
Returns the last client trust validation result, including captured certificates and validation status.- Returns:
- an
TrustValidationResultcontaining the results of the last client trust validation, ornullif no validation has been performed yet.
-
getLastServerTrustValidationResult
public TrustValidationResult getLastServerTrustValidationResult()
Returns the last server trust validation result, including captured certificates and validation status.- Returns:
- an
TrustValidationResultcontaining the results of the last server trust validation, ornullif no validation has been performed yet.
-
getCapturedServerCertificates
public X509Certificate[] getCapturedServerCertificates()
The most recently captured server certificate chain as a list.
-
getCapturedClientCertificates
public X509Certificate[] getCapturedClientCertificates()
The most recently captured client certificate chain as a list.
-
getServerTrustValidationPassed
public Boolean getServerTrustValidationPassed()
Indicates whether the last server trust validation passed.
-
getClientTrustValidationPassed
public Boolean getClientTrustValidationPassed()
Indicates whether the last client trust validation passed.
-
getServerTrustValidationException
public CertificateException getServerTrustValidationException()
The exception thrown during the last server trust validation, if any.
-
getClientTrustValidationException
public CertificateException getClientTrustValidationException()
The exception thrown during the last client trust validation, if any.
-
-