AuthSSLProtocolSocketFactory.java
2.05 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.commons.httpclient.HttpClientError
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.replication.impl.transport;
import com.day.cq.replication.impl.transport.EasySSLProtocolSocketFactory;
import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import org.apache.commons.httpclient.HttpClientError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AuthSSLProtocolSocketFactory
extends EasySSLProtocolSocketFactory {
private static final Logger LOG = LoggerFactory.getLogger(AuthSSLProtocolSocketFactory.class);
private SSLContext sslcontext;
private KeyManager keyManager;
private TrustManager trustManager;
public AuthSSLProtocolSocketFactory(KeyManager keyManager, TrustManager trustManager, String[] disabledSuites, String[] enabledSuites) {
super(disabledSuites, enabledSuites);
this.keyManager = keyManager;
this.trustManager = trustManager;
}
private SSLContext createSSLContext() {
try {
SSLContext sslcontext = SSLContext.getInstance("SSL");
sslcontext.init(new KeyManager[]{this.keyManager}, new TrustManager[]{this.trustManager}, new SecureRandom());
return sslcontext;
}
catch (NoSuchAlgorithmException e) {
LOG.error(e.getMessage(), (Throwable)e);
throw new HttpClientError("Unsupported algorithm exception: " + e.getMessage());
}
catch (GeneralSecurityException e) {
LOG.error(e.getMessage(), (Throwable)e);
throw new HttpClientError("Key management exception: " + e.getMessage());
}
}
@Override
protected SSLContext getSSLContext() {
if (this.sslcontext == null) {
this.sslcontext = this.createSSLContext();
}
return this.sslcontext;
}
}