AuthSSLX509TrustManager.java
2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.replication.impl.transport;
import java.security.Principal;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Date;
import javax.net.ssl.X509TrustManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AuthSSLX509TrustManager
implements X509TrustManager {
private X509TrustManager defaultTrustManager = null;
private static final Logger LOG = LoggerFactory.getLogger(AuthSSLX509TrustManager.class);
public AuthSSLX509TrustManager(X509TrustManager defaultTrustManager) {
if (defaultTrustManager == null) {
throw new IllegalArgumentException("Trust manager may not be null");
}
this.defaultTrustManager = defaultTrustManager;
}
@Override
public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
if (LOG.isDebugEnabled() && certificates != null) {
for (int c = 0; c < certificates.length; ++c) {
LOG.debug("------------------------------------------");
X509Certificate cert = certificates[c];
LOG.debug(" Client certificate " + (c + 1) + ":");
LOG.debug(" Subject DN: " + cert.getSubjectDN());
LOG.debug(" Signature Algorithm: " + cert.getSigAlgName());
LOG.debug(" Valid from: " + cert.getNotBefore());
LOG.debug(" Valid until: " + cert.getNotAfter());
LOG.debug(" Issuer: " + cert.getIssuerDN());
LOG.debug("------------------------------------------");
}
}
this.defaultTrustManager.checkClientTrusted(certificates, authType);
}
@Override
public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
if (LOG.isDebugEnabled() && certificates != null) {
for (int c = 0; c < certificates.length; ++c) {
X509Certificate cert = certificates[c];
LOG.debug("------------------------------------------");
LOG.debug(" Server certificate " + (c + 1) + ":");
LOG.debug(" Subject DN: " + cert.getSubjectDN());
LOG.debug(" Signature Algorithm: " + cert.getSigAlgName());
LOG.debug(" Valid from: " + cert.getNotBefore());
LOG.debug(" Valid until: " + cert.getNotAfter());
LOG.debug(" Issuer: " + cert.getIssuerDN());
LOG.debug("------------------------------------------");
}
}
this.defaultTrustManager.checkServerTrusted(certificates, authType);
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return this.defaultTrustManager.getAcceptedIssuers();
}
}