0N/A/*
5361N/A * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
5361N/A//
5361N/A// SunJSSE does not support dynamic system properties, no way to re-use
5361N/A// system properties in samevm/agentvm mode.
5361N/A//
5361N/A
0N/A/*
0N/A * @test
0N/A * @bug 4635454 6208022
0N/A * @summary Check pluggability of SSLSocketFactory and
0N/A * SSLServerSocketFactory classes.
5361N/A * @run main/othervm CheckSockFacExport1
0N/A */
0N/A
0N/Aimport java.util.*;
0N/A
0N/Aimport java.security.*;
0N/Aimport java.net.*;
0N/Aimport javax.net.ssl.*;
0N/A
0N/Apublic class CheckSockFacExport1 {
0N/A
0N/A public static void main(String argv[]) throws Exception {
5361N/A // reserve the security properties
5361N/A String reservedSFacAlg =
5361N/A Security.getProperty("ssl.SocketFactory.provider");
5361N/A String reservedSSFacAlg =
5361N/A Security.getProperty("ssl.ServerSocketFactory.provider");
5361N/A
5361N/A try {
5361N/A Security.setProperty("ssl.SocketFactory.provider",
5361N/A "MySSLSocketFacImpl");
5361N/A MySSLSocketFacImpl.useCustomCipherSuites();
5361N/A Security.setProperty("ssl.ServerSocketFactory.provider",
5361N/A "MySSLServerSocketFacImpl");
5361N/A MySSLServerSocketFacImpl.useCustomCipherSuites();
0N/A
5361N/A String[] supportedCS = null;
5361N/A for (int i = 0; i < 2; i++) {
5361N/A switch (i) {
5361N/A case 0:
5361N/A System.out.println("Testing SSLSocketFactory:");
5361N/A SSLSocketFactory sf = (SSLSocketFactory)
5361N/A SSLSocketFactory.getDefault();
5361N/A supportedCS = sf.getSupportedCipherSuites();
5361N/A break;
5361N/A case 1:
5361N/A System.out.println("Testing SSLServerSocketFactory:");
5361N/A SSLServerSocketFactory ssf = (SSLServerSocketFactory)
5361N/A SSLServerSocketFactory.getDefault();
5361N/A supportedCS = ssf.getSupportedCipherSuites();
5361N/A break;
5361N/A default:
5361N/A throw new Exception("Internal Test Error");
5361N/A }
5361N/A System.out.println(Arrays.asList(supportedCS));
5361N/A if (supportedCS.length == 0) {
5361N/A throw new Exception("supported ciphersuites are empty");
5361N/A }
0N/A }
5361N/A System.out.println("Test Passed");
5361N/A } finally {
5361N/A // restore the security properties
5361N/A if (reservedSFacAlg == null) {
5361N/A reservedSFacAlg = "";
0N/A }
5361N/A
5361N/A if (reservedSSFacAlg == null) {
5361N/A reservedSSFacAlg = "";
5361N/A }
5361N/A Security.setProperty("ssl.SocketFactory.provider",
5361N/A reservedSFacAlg);
5361N/A Security.setProperty("ssl.ServerSocketFactory.provider",
5361N/A reservedSSFacAlg);
0N/A }
0N/A }
0N/A}