Path: blob/master/test/jdk/javax/net/ssl/sanity/pluggability/MySSLSocketFacImpl.java
41154 views
/*1* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.IOException;24import java.util.*;25import java.security.cert.Certificate;26import java.security.cert.X509Certificate;27import java.security.*;28import java.net.*;29import javax.net.*;30import javax.net.ssl.*;3132public class MySSLSocketFacImpl extends SSLSocketFactory {33private static String[] supportedCS = CipherSuites.CUSTOM;3435public static void useStandardCipherSuites() {36supportedCS = CipherSuites.STANDARD;37}38public static void useCustomCipherSuites() {39supportedCS = CipherSuites.CUSTOM;40}4142public MySSLSocketFacImpl() {43super();44}45public String[] getDefaultCipherSuites() {46return (String[]) supportedCS.clone();47}48public String[] getSupportedCipherSuites() {49return getDefaultCipherSuites();50}51public Socket createSocket(Socket s, String host, int port,52boolean autoClose) { return new MySSLSocket(this); }53public Socket createSocket(InetAddress host, int port) {54return new MySSLSocket(this);55}56public Socket createSocket(InetAddress address, int port,57InetAddress localAddress, int localPort) {58return new MySSLSocket(this);59}60public Socket createSocket(String host, int port) {61return new MySSLSocket(this);62}63public Socket createSocket(String host, int port, InetAddress64localHost, int localPort) { return new MySSLSocket(this); }65}6667class MySSLSocket extends SSLSocket {68SSLSocketFactory fac = null;6970public MySSLSocket(SSLSocketFactory fac) {71this.fac = fac;72}73public String[] getSupportedCipherSuites() {74return fac.getSupportedCipherSuites();75}76public String[] getEnabledCipherSuites() {77return fac.getSupportedCipherSuites();78}79public void setEnabledCipherSuites(String suites[]) {}80public String[] getSupportedProtocols() { return null; }81public String[] getEnabledProtocols() { return null; }82public void setEnabledProtocols(String protocols[]) {}83public SSLSession getSession() { return null; }84public void addHandshakeCompletedListener85(HandshakeCompletedListener listener) {}86public void removeHandshakeCompletedListener87(HandshakeCompletedListener listener) {}88public void startHandshake() throws IOException {}89public void setUseClientMode(boolean mode) {}90public boolean getUseClientMode() { return true; }91public void setNeedClientAuth(boolean need) {}92public boolean getNeedClientAuth() { return false; }93public void setWantClientAuth(boolean want) {}94public boolean getWantClientAuth() { return false; }95public void setEnableSessionCreation(boolean flag) {}96public boolean getEnableSessionCreation() { return true; }97}9899100