1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.net.ssl;
15
16 import java.io.IOException;
17 import java.net.InetAddress;
18 import java.net.ServerSocket;
19
20 import javax.net.ServerSocketFactory;
21 import javax.net.ssl.SSLServerSocket;
22 import javax.net.ssl.SSLServerSocketFactory;
23
24
25
26
27
28
29
30
31
32
33
34
35 public class ConfigurableSSLServerSocketFactory extends ServerSocketFactory {
36
37 private final SSLParametersConfiguration parameters;
38 private final SSLServerSocketFactory delegate;
39
40
41
42
43
44
45
46
47
48 public ConfigurableSSLServerSocketFactory(SSLParametersConfiguration parameters, SSLServerSocketFactory delegate) {
49 this.parameters = parameters;
50 this.delegate = delegate;
51 }
52
53
54
55
56 @Override
57 public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException {
58 SSLServerSocket socket = (SSLServerSocket) delegate.createServerSocket(port, backlog, ifAddress);
59 parameters.configure(new SSLConfigurableServerSocket(socket));
60 return socket;
61 }
62
63
64
65
66 @Override
67 public ServerSocket createServerSocket(int port, int backlog) throws IOException {
68 SSLServerSocket socket = (SSLServerSocket) delegate.createServerSocket(port, backlog);
69 parameters.configure(new SSLConfigurableServerSocket(socket));
70 return socket;
71 }
72
73
74
75
76 @Override
77 public ServerSocket createServerSocket(int port) throws IOException {
78 SSLServerSocket socket = (SSLServerSocket) delegate.createServerSocket(port);
79 parameters.configure(new SSLConfigurableServerSocket(socket));
80 return socket;
81 }
82
83 }