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