1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.internal.transport.http;
11
12 import java.io.IOException;
13 import java.net.InetAddress;
14 import java.net.Socket;
15
16 import javax.net.ssl.SSLSocket;
17 import javax.net.ssl.SSLSocketFactory;
18
19
20
21
22
23
24 public abstract class DelegatingSSLSocketFactory extends SSLSocketFactory {
25
26 private final SSLSocketFactory delegate;
27
28
29
30
31
32
33
34
35 public DelegatingSSLSocketFactory(SSLSocketFactory delegate) {
36 this.delegate = delegate;
37 }
38
39 @Override
40 public SSLSocket createSocket() throws IOException {
41 return prepare(delegate.createSocket());
42 }
43
44 @Override
45 public SSLSocket createSocket(String host, int port) throws IOException {
46 return prepare(delegate.createSocket(host, port));
47 }
48
49 @Override
50 public SSLSocket createSocket(String host, int port,
51 InetAddress localAddress, int localPort) throws IOException {
52 return prepare(
53 delegate.createSocket(host, port, localAddress, localPort));
54 }
55
56 @Override
57 public SSLSocket createSocket(InetAddress host, int port)
58 throws IOException {
59 return prepare(delegate.createSocket(host, port));
60 }
61
62 @Override
63 public SSLSocket createSocket(InetAddress host, int port,
64 InetAddress localAddress, int localPort) throws IOException {
65 return prepare(
66 delegate.createSocket(host, port, localAddress, localPort));
67 }
68
69 @Override
70 public SSLSocket createSocket(Socket socket, String host, int port,
71 boolean autoClose) throws IOException {
72 return prepare(delegate.createSocket(socket, host, port, autoClose));
73 }
74
75 @Override
76 public String[] getDefaultCipherSuites() {
77 return delegate.getDefaultCipherSuites();
78 }
79
80 @Override
81 public String[] getSupportedCipherSuites() {
82 return delegate.getSupportedCipherSuites();
83 }
84
85 private SSLSocket prepare(Socket socket) throws IOException {
86 SSLSocket sslSocket = (SSLSocket) socket;
87 configure(sslSocket);
88 return sslSocket;
89 }
90
91
92
93
94
95
96
97
98
99 protected abstract void configure(SSLSocket socket) throws IOException;
100
101 }