Coverage Report - ca.uhn.hl7v2.hoh.util.HapiSocketTlsFactoryWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
HapiSocketTlsFactoryWrapper
0%
0/9
N/A
1
 
 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  
  * Wraps an HoH {@link ISocketFactory} instance for use in HAPI. Note that the
 16  
  * wrapped methods will only be used to create TLS socket instances.
 17  
  */
 18  
 public class HapiSocketTlsFactoryWrapper implements SocketFactory {
 19  
 
 20  
         private ISocketFactory mySocketFactory;
 21  
 
 22  
         /**
 23  
          * Constuctor
 24  
          * 
 25  
          * @param theSocketFactoryToWrap
 26  
          *            The socket factory to wrap. This instance will only be used
 27  
          *            for {@link #createTlsSocket()} and
 28  
          *            {@link #createTlsServerSocket()}
 29  
          */
 30  0
         public HapiSocketTlsFactoryWrapper(ISocketFactory theSocketFactoryToWrap) {
 31  0
                 mySocketFactory = theSocketFactoryToWrap;
 32  0
         }
 33  
 
 34  
         /**
 35  
          * {@inheritDoc}
 36  
          */
 37  
         public Socket createSocket() throws IOException {
 38  0
                 return javax.net.SocketFactory.getDefault().createSocket();
 39  
         }
 40  
 
 41  
         /**
 42  
          * {@inheritDoc}
 43  
          */
 44  
         public Socket createTlsSocket() throws IOException {
 45  0
                 return mySocketFactory.createClientSocket();
 46  
         }
 47  
 
 48  
         /**
 49  
          * {@inheritDoc}
 50  
          */
 51  
         public ServerSocket createServerSocket() throws IOException {
 52  0
                 return ServerSocketFactory.getDefault().createServerSocket();
 53  
         }
 54  
 
 55  
         /**
 56  
          * {@inheritDoc}
 57  
          */
 58  
         public ServerSocket createTlsServerSocket() throws IOException {
 59  0
                 return mySocketFactory.createServerSocket();
 60  
         }
 61  
 
 62  
         public void configureNewAcceptedSocket(Socket theSocket) throws SocketException {
 63  0
                 theSocket.setSoTimeout(StandardSocketFactory.DEFAULT_ACCEPTED_SOCKET_TIMEOUT);
 64  0
         }
 65  
 
 66  
 }