J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | * accompanied this code). |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License version |
| 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 21 | * have any questions. |
| 22 | */ |
| 23 | |
| 24 | import java.io.IOException; |
| 25 | import java.util.*; |
| 26 | import java.security.cert.Certificate; |
| 27 | import java.security.cert.X509Certificate; |
| 28 | import java.security.*; |
| 29 | import java.net.*; |
| 30 | import javax.net.*; |
| 31 | import javax.net.ssl.*; |
| 32 | |
| 33 | public class MySSLSocketFacImpl extends SSLSocketFactory { |
| 34 | private static String[] supportedCS = CipherSuites.CUSTOM; |
| 35 | |
| 36 | public static void useStandardCipherSuites() { |
| 37 | supportedCS = CipherSuites.STANDARD; |
| 38 | } |
| 39 | public static void useCustomCipherSuites() { |
| 40 | supportedCS = CipherSuites.CUSTOM; |
| 41 | } |
| 42 | |
| 43 | public MySSLSocketFacImpl() { |
| 44 | super(); |
| 45 | } |
| 46 | public String[] getDefaultCipherSuites() { |
| 47 | return (String[]) supportedCS.clone(); |
| 48 | } |
| 49 | public String[] getSupportedCipherSuites() { |
| 50 | return getDefaultCipherSuites(); |
| 51 | } |
| 52 | public Socket createSocket(Socket s, String host, int port, |
| 53 | boolean autoClose) { return new MySSLSocket(this); } |
| 54 | public Socket createSocket(InetAddress host, int port) { |
| 55 | return new MySSLSocket(this); |
| 56 | } |
| 57 | public Socket createSocket(InetAddress address, int port, |
| 58 | InetAddress localAddress, int localPort) { |
| 59 | return new MySSLSocket(this); |
| 60 | } |
| 61 | public Socket createSocket(String host, int port) { |
| 62 | return new MySSLSocket(this); |
| 63 | } |
| 64 | public Socket createSocket(String host, int port, InetAddress |
| 65 | localHost, int localPort) { return new MySSLSocket(this); } |
| 66 | } |
| 67 | |
| 68 | class MySSLSocket extends SSLSocket { |
| 69 | SSLSocketFactory fac = null; |
| 70 | |
| 71 | public MySSLSocket(SSLSocketFactory fac) { |
| 72 | this.fac = fac; |
| 73 | } |
| 74 | public String[] getSupportedCipherSuites() { |
| 75 | return fac.getSupportedCipherSuites(); |
| 76 | } |
| 77 | public String[] getEnabledCipherSuites() { |
| 78 | return fac.getSupportedCipherSuites(); |
| 79 | } |
| 80 | public void setEnabledCipherSuites(String suites[]) {} |
| 81 | public String[] getSupportedProtocols() { return null; } |
| 82 | public String[] getEnabledProtocols() { return null; } |
| 83 | public void setEnabledProtocols(String protocols[]) {} |
| 84 | public SSLSession getSession() { return null; } |
| 85 | public void addHandshakeCompletedListener |
| 86 | (HandshakeCompletedListener listener) {} |
| 87 | public void removeHandshakeCompletedListener |
| 88 | (HandshakeCompletedListener listener) {} |
| 89 | public void startHandshake() throws IOException {} |
| 90 | public void setUseClientMode(boolean mode) {} |
| 91 | public boolean getUseClientMode() { return true; } |
| 92 | public void setNeedClientAuth(boolean need) {} |
| 93 | public boolean getNeedClientAuth() { return false; } |
| 94 | public void setWantClientAuth(boolean want) {} |
| 95 | public boolean getWantClientAuth() { return false; } |
| 96 | public void setEnableSessionCreation(boolean flag) {} |
| 97 | public boolean getEnableSessionCreation() { return true; } |
| 98 | } |