public final class ReplicationTrustManager
extends java.lang.Object
implements javax.net.ssl.X509TrustManager
| Modifier and Type | Field and Description |
|---|---|
private static ReplicationTrustManager |
INSTANCE
the singleton instance of this trust manager
|
private static java.security.KeyStore |
ks
the in-memory keystore in JKS format
|
private static org.slf4j.Logger |
LOG
A logger for this class
|
private static org.bouncycastle.jce.provider.X509CertParser |
parser
the X509 certificate parser
|
private static javax.net.ssl.X509TrustManager |
trustManager
the internal trust manager used for verifying the certificates
|
| Modifier | Constructor and Description |
|---|---|
private |
ReplicationTrustManager()
Creates a instance of ReplicationTrustManager
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addCertificate(java.lang.String certAlias,
byte[] certificate)
stores the given certificate into the keystore with the given alias name
|
static void |
addCertificates(java.util.Map<java.lang.String,byte[]> aliasCertMap)
loads the given map of [alias-name, certificate-data] entries into the keystore
to be used by the trust manager
|
void |
checkClientTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType) |
void |
checkServerTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType) |
java.security.cert.X509Certificate[] |
getAcceptedIssuers() |
static ReplicationTrustManager |
getInstance()
returns the singleton instance of ReplicationTrustManager, note that this
return instance can only be used after calling the
addCertificates(Map) method |
private static final org.slf4j.Logger LOG
private static javax.net.ssl.X509TrustManager trustManager
private static java.security.KeyStore ks
private static org.bouncycastle.jce.provider.X509CertParser parser
private static final ReplicationTrustManager INSTANCE
private ReplicationTrustManager()
public static void addCertificates(java.util.Map<java.lang.String,byte[]> aliasCertMap)
throws java.lang.Exception
aliasCertMap - the map of [alias-name, certificate-data] entriesjava.lang.Exception - in case of any issues related to certificate data parsingpublic static void addCertificate(java.lang.String certAlias,
byte[] certificate)
throws java.lang.Exception
certAlias - the alias name to be used for this certificatecertificate - the X509 certificate datajava.lang.Exception - in case of any issues related to certificate data parsingpublic static ReplicationTrustManager getInstance()
addCertificates(Map) methodpublic void checkClientTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType)
throws java.security.cert.CertificateException
checkClientTrusted in interface javax.net.ssl.X509TrustManagerjava.security.cert.CertificateExceptionpublic void checkServerTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType)
throws java.security.cert.CertificateException
checkServerTrusted in interface javax.net.ssl.X509TrustManagerjava.security.cert.CertificateExceptionpublic java.security.cert.X509Certificate[] getAcceptedIssuers()
getAcceptedIssuers in interface javax.net.ssl.X509TrustManager