AnonCipherWithWantClientAuth.java revision 16238:0ad126a1f49e
1/* 2 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24// 25// SunJSSE does not support dynamic system properties, no way to re-use 26// system properties in samevm/agentvm mode. 27// 28 29/* 30 * @test 31 * @bug 4392475 32 * @library /javax/net/ssl/templates 33 * @summary Calling setWantClientAuth(true) disables anonymous suites 34 * @run main/othervm AnonCipherWithWantClientAuth 35 */ 36 37import java.io.InputStream; 38import java.io.OutputStream; 39import java.security.Security; 40import javax.net.ssl.SSLSocket; 41 42public class AnonCipherWithWantClientAuth extends SSLSocketTemplate { 43 /* 44 * Run the test case. 45 */ 46 public static void main(String[] args) throws Exception { 47 // reset the security property to make sure that the algorithms 48 // and keys used in this test are not disabled. 49 Security.setProperty("jdk.tls.disabledAlgorithms", ""); 50 Security.setProperty("jdk.certpath.disabledAlgorithms", ""); 51 52 (new AnonCipherWithWantClientAuth()).run(); 53 } 54 55 @Override 56 protected void runServerApplication(SSLSocket socket) throws Exception { 57 String ciphers[] = { 58 "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", 59 "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", 60 "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" }; 61 socket.setEnabledCipherSuites(ciphers); 62 socket.setWantClientAuth(true); 63 64 InputStream sslIS = socket.getInputStream(); 65 OutputStream sslOS = socket.getOutputStream(); 66 67 sslIS.read(); 68 sslOS.write(85); 69 sslOS.flush(); 70 } 71 72 @Override 73 protected void runClientApplication(SSLSocket socket) throws Exception { 74 String ciphers[] = { 75 "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", 76 "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5" }; 77 socket.setEnabledCipherSuites(ciphers); 78 socket.setUseClientMode(true); 79 80 InputStream sslIS = socket.getInputStream(); 81 OutputStream sslOS = socket.getOutputStream(); 82 83 sslOS.write(280); 84 sslOS.flush(); 85 sslIS.read(); 86 } 87} 88