1 package ca.uhn.hl7v2.hoh.util;
2
3 import java.io.IOException;
4 import java.net.ServerSocket;
5 import java.net.Socket;
6 import java.net.SocketException;
7
8 import javax.net.ServerSocketFactory;
9
10 import ca.uhn.hl7v2.hoh.sockets.ISocketFactory;
11 import ca.uhn.hl7v2.util.SocketFactory;
12 import ca.uhn.hl7v2.util.StandardSocketFactory;
13
14
15
16
17
18 public class HapiSocketTlsFactoryWrapper implements SocketFactory {
19
20 private final ISocketFactory mySocketFactory;
21
22
23
24
25
26
27
28
29
30 public HapiSocketTlsFactoryWrapper(ISocketFactory theSocketFactoryToWrap) {
31 mySocketFactory = theSocketFactoryToWrap;
32 }
33
34
35
36
37 public Socket createSocket() throws IOException {
38 return javax.net.SocketFactory.getDefault().createSocket();
39 }
40
41
42
43
44 public Socket createTlsSocket() throws IOException {
45 return mySocketFactory.createClientSocket();
46 }
47
48
49
50
51 public ServerSocket createServerSocket() throws IOException {
52 return ServerSocketFactory.getDefault().createServerSocket();
53 }
54
55
56
57
58 public ServerSocket createTlsServerSocket() throws IOException {
59 return mySocketFactory.createServerSocket();
60 }
61
62 public void configureNewAcceptedSocket(Socket theSocket) throws SocketException {
63 theSocket.setSoTimeout(StandardSocketFactory.DEFAULT_ACCEPTED_SOCKET_TIMEOUT);
64 }
65
66 }