1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.transport.ssl; |
12 | |
|
13 | |
import org.mule.api.security.tls.TlsConfiguration; |
14 | |
import org.mule.transport.tcp.TcpServerSocketFactory; |
15 | |
|
16 | |
import java.io.IOException; |
17 | |
import java.net.InetAddress; |
18 | |
import java.net.ServerSocket; |
19 | |
import java.net.InetSocketAddress; |
20 | |
|
21 | |
import javax.net.ServerSocketFactory; |
22 | |
|
23 | |
public class SslServerSocketFactory extends TcpServerSocketFactory |
24 | |
{ |
25 | |
|
26 | |
private TlsConfiguration tls; |
27 | |
|
28 | |
public SslServerSocketFactory(TlsConfiguration tls) |
29 | 58 | { |
30 | 58 | this.tls = tls; |
31 | 58 | } |
32 | |
|
33 | |
|
34 | |
public ServerSocket createServerSocket(InetAddress address, int port, int backlog, Boolean reuse) throws IOException |
35 | |
{ |
36 | |
try |
37 | |
{ |
38 | 0 | ServerSocketFactory ssf = tls.getServerSocketFactory(); |
39 | 0 | return configure(ssf.createServerSocket(), reuse, new InetSocketAddress(address, port), backlog); |
40 | |
} |
41 | 0 | catch (IOException e) |
42 | |
{ |
43 | 0 | throw e; |
44 | |
} |
45 | 0 | catch (Exception e) |
46 | |
{ |
47 | 0 | throw (IOException) new IOException(e.getMessage()).initCause(e); |
48 | |
} |
49 | |
} |
50 | |
|
51 | |
|
52 | |
public ServerSocket createServerSocket(int port, int backlog, Boolean reuse) throws IOException |
53 | |
{ |
54 | |
try |
55 | |
{ |
56 | 52 | ServerSocketFactory ssf = tls.getServerSocketFactory(); |
57 | 52 | return configure(ssf.createServerSocket(), reuse, new InetSocketAddress(port), backlog); |
58 | |
} |
59 | 0 | catch (IOException e) |
60 | |
{ |
61 | 0 | throw e; |
62 | |
} |
63 | 0 | catch (Exception e) |
64 | |
{ |
65 | 0 | throw (IOException) new IOException(e.getMessage()).initCause(e); |
66 | |
} |
67 | |
} |
68 | |
|
69 | |
} |