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 | /* |
| 25 | * @test |
| 26 | * @bug 4635454 |
| 27 | * @summary Check pluggability of SSLSocketFactory and |
| 28 | * SSLServerSocketFactory classes. |
| 29 | */ |
| 30 | import java.security.*; |
| 31 | import java.net.*; |
| 32 | import javax.net.ssl.*; |
| 33 | |
| 34 | public class CheckSockFacExport2 { |
| 35 | |
| 36 | public static void main(String argv[]) throws Exception { |
| 37 | Security.setProperty("ssl.SocketFactory.provider", |
| 38 | "MySSLSocketFacImpl"); |
| 39 | MySSLSocketFacImpl.useStandardCipherSuites(); |
| 40 | Security.setProperty("ssl.ServerSocketFactory.provider", |
| 41 | "MySSLServerSocketFacImpl"); |
| 42 | MySSLServerSocketFacImpl.useStandardCipherSuites(); |
| 43 | |
| 44 | boolean result = false; |
| 45 | for (int i = 0; i < 2; i++) { |
| 46 | switch (i) { |
| 47 | case 0: |
| 48 | System.out.println("Testing SSLSocketFactory:"); |
| 49 | SSLSocketFactory sf = (SSLSocketFactory) |
| 50 | SSLSocketFactory.getDefault(); |
| 51 | result = (sf instanceof MySSLSocketFacImpl); |
| 52 | break; |
| 53 | |
| 54 | case 1: |
| 55 | System.out.println("Testing SSLServerSocketFactory:"); |
| 56 | SSLServerSocketFactory ssf = (SSLServerSocketFactory) |
| 57 | SSLServerSocketFactory.getDefault(); |
| 58 | result = (ssf instanceof MySSLServerSocketFacImpl); |
| 59 | break; |
| 60 | default: |
| 61 | throw new Exception("Internal Test Error"); |
| 62 | } |
| 63 | if (result) { |
| 64 | System.out.println("...accepted valid SFs"); |
| 65 | } else { |
| 66 | throw new Exception("...wrong SF is used"); |
| 67 | } |
| 68 | } |
| 69 | System.out.println("Test Passed"); |
| 70 | } |
| 71 | } |