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.AbstractTcpSocketFactory;
15 import org.mule.transport.tcp.TcpSocketKey;
16
17 import java.io.IOException;
18 import java.net.Socket;
19 import java.security.KeyManagementException;
20 import java.security.NoSuchAlgorithmException;
21
22 public class SslSocketFactory extends AbstractTcpSocketFactory
23 {
24
25 private TlsConfiguration tls;
26
27 public SslSocketFactory(TlsConfiguration tls)
28 {
29 this.tls = tls;
30 }
31
32 protected Socket createSocket(TcpSocketKey key) throws IOException
33 {
34 try
35 {
36 return tls.getSocketFactory().createSocket(key.getInetAddress(), key.getPort());
37 }
38 catch (NoSuchAlgorithmException e)
39 {
40 throw (IOException) new IOException(e.getMessage()).initCause(e);
41 }
42 catch (KeyManagementException e)
43 {
44 throw (IOException) new IOException(e.getMessage()).initCause(e);
45 }
46 }
47
48 }