View Javadoc

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