View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.ssl;
8   
9   import java.io.IOException;
10  import java.io.InputStream;
11  import java.io.OutputStream;
12  import java.net.InetSocketAddress;
13  import java.net.SocketAddress;
14  
15  import javax.net.ssl.HandshakeCompletedListener;
16  import javax.net.ssl.SSLSession;
17  import javax.net.ssl.SSLSocket;
18  
19  /**
20   * {@link SSLSocket} subclass that can be used to mock SSL related tests
21   */
22  public class MockSslSocket extends SSLSocket
23  {
24      
25      public void addHandshakeCompletedListener(HandshakeCompletedListener listener)
26      {
27          // not needed
28      }
29  
30      public boolean getEnableSessionCreation()
31      {
32          return false;
33      }
34  
35      public String[] getEnabledCipherSuites()
36      {
37          return null;
38      }
39  
40      public String[] getEnabledProtocols()
41      {
42          return null;
43      }
44  
45      public boolean getNeedClientAuth()
46      {
47          return false;
48      }
49  
50      public SSLSession getSession()
51      {
52          return null;
53      }
54  
55      public String[] getSupportedCipherSuites()
56      {
57          return null;
58      }
59  
60      public String[] getSupportedProtocols()
61      {
62          return null;
63      }
64  
65      public boolean getUseClientMode()
66      {
67          return false;
68      }
69  
70      public boolean getWantClientAuth()
71      {
72          return false;
73      }
74  
75      public void removeHandshakeCompletedListener(HandshakeCompletedListener listener)
76      {
77          // not needed
78      }
79  
80      public void setEnableSessionCreation(boolean flag)
81      {
82          // not needed
83      }
84  
85      public void setEnabledCipherSuites(String[] suites)
86      {
87          // not needed
88      }
89  
90      public void setEnabledProtocols(String[] protocols)
91      {
92          // not needed
93      }
94  
95      public void setNeedClientAuth(boolean need)
96      {
97          // not needed
98      }
99  
100     public void setUseClientMode(boolean mode)
101     {
102         // not needed
103     }
104 
105     public void setWantClientAuth(boolean want)
106     {
107         // not needed
108     }
109 
110     public void startHandshake() throws IOException
111     {
112         // not needed
113     }
114     
115     @Override
116     public InputStream getInputStream() throws IOException
117     {
118         return null;
119     }
120 
121     @Override
122     public OutputStream getOutputStream() throws IOException
123     {
124         return null;
125     }
126 
127     @Override
128     public SocketAddress getRemoteSocketAddress()
129     {
130         return new InetSocketAddress("localhost", 12345);
131     }
132 
133 }
134