1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.net.server;
15
16 import javax.net.ServerSocketFactory;
17 import javax.net.ssl.SSLContext;
18
19 import ch.qos.logback.core.net.ssl.ConfigurableSSLServerSocketFactory;
20 import ch.qos.logback.core.net.ssl.SSLComponent;
21 import ch.qos.logback.core.net.ssl.SSLConfiguration;
22 import ch.qos.logback.core.net.ssl.SSLParametersConfiguration;
23
24
25
26
27
28
29 public class SSLServerSocketReceiver extends ServerSocketReceiver implements SSLComponent {
30
31 private SSLConfiguration ssl;
32 private ServerSocketFactory socketFactory;
33
34
35
36
37 @Override
38 protected ServerSocketFactory getServerSocketFactory() throws Exception {
39 if (socketFactory == null) {
40 SSLContext sslContext = getSsl().createContext(this);
41 SSLParametersConfiguration parameters = getSsl().getParameters();
42 parameters.setContext(getContext());
43 socketFactory = new ConfigurableSSLServerSocketFactory(parameters, sslContext.getServerSocketFactory());
44 }
45 return socketFactory;
46 }
47
48
49
50
51
52
53
54 public SSLConfiguration getSsl() {
55 if (ssl == null) {
56 ssl = new SSLConfiguration();
57 }
58 return ssl;
59 }
60
61
62
63
64
65
66 public void setSsl(SSLConfiguration ssl) {
67 this.ssl = ssl;
68 }
69
70 }