1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.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
30
31 public abstract class SSLServerSocketAppenderBase<E> extends AbstractServerSocketAppender<E> implements SSLComponent {
32
33 private SSLConfiguration ssl;
34 private ServerSocketFactory socketFactory;
35
36 @Override
37 protected ServerSocketFactory getServerSocketFactory() {
38 return socketFactory;
39 }
40
41
42
43
44 @Override
45 public void start() {
46 try {
47 SSLContext sslContext = getSsl().createContext(this);
48 SSLParametersConfiguration parameters = getSsl().getParameters();
49 parameters.setContext(getContext());
50 socketFactory = new ConfigurableSSLServerSocketFactory(parameters, sslContext.getServerSocketFactory());
51 super.start();
52 } catch (Exception ex) {
53 addError(ex.getMessage(), ex);
54 }
55 }
56
57
58
59
60
61
62
63 public SSLConfiguration getSsl() {
64 if (ssl == null) {
65 ssl = new SSLConfiguration();
66 }
67 return ssl;
68 }
69
70
71
72
73
74
75 public void setSsl(SSLConfiguration ssl) {
76 this.ssl = ssl;
77 }
78
79 }