1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.providers.ssl; |
12 | |
|
13 | |
import org.mule.providers.tcp.TcpSocketFactory; |
14 | |
import org.mule.umo.security.tls.TlsConfiguration; |
15 | |
|
16 | |
import java.io.IOException; |
17 | |
import java.net.InetAddress; |
18 | |
import java.net.Socket; |
19 | |
import java.security.KeyManagementException; |
20 | |
import java.security.NoSuchAlgorithmException; |
21 | |
|
22 | |
public class SslSocketFactory extends TcpSocketFactory |
23 | |
{ |
24 | |
|
25 | |
private TlsConfiguration tls; |
26 | |
|
27 | |
public SslSocketFactory(TlsConfiguration tls) |
28 | 0 | { |
29 | 0 | this.tls = tls; |
30 | 0 | } |
31 | |
|
32 | |
|
33 | |
protected Socket createSocket(int port, InetAddress inetAddress) throws IOException |
34 | |
{ |
35 | |
try |
36 | |
{ |
37 | 0 | return tls.getSocketFactory().createSocket(inetAddress, port); |
38 | |
} |
39 | 0 | catch (NoSuchAlgorithmException e) |
40 | |
{ |
41 | 0 | throw (IOException) new IOException(e.getMessage()).initCause(e); |
42 | |
} |
43 | 0 | catch (KeyManagementException e) |
44 | |
{ |
45 | 0 | throw (IOException) new IOException(e.getMessage()).initCause(e); |
46 | |
} |
47 | |
} |
48 | |
|
49 | |
} |