Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/net/ssl/FixingJavadocs/SSLSessionNulls.java
38853 views
/*1* Copyright (c) 2001, 2017, 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*/2223/*24* @test25* @bug 438788226* @summary Need to revisit the javadocs for JSSE, especially the27* promoted classes.28* @library /javax/net/ssl/templates29* @run main/othervm SSLSessionNulls30*31* SunJSSE does not support dynamic system properties, no way to re-use32* system properties in samevm/agentvm mode.33* @author Brad Wetmore34*/3536import java.io.IOException;37import java.io.InputStream;38import java.io.OutputStream;3940import javax.net.ssl.SSLSession;41import javax.net.ssl.SSLSocket;4243public class SSLSessionNulls extends SSLSocketTemplate {4445@Override46protected void runServerApplication(SSLSocket socket) throws Exception {47InputStream sslIS = socket.getInputStream();48OutputStream sslOS = socket.getOutputStream();4950sslIS.read();51sslOS.write(85);52sslOS.flush();53}5455@Override56protected void runClientApplication(SSLSocket socket) throws Exception {57InputStream sslIS = socket.getInputStream();58OutputStream sslOS = socket.getOutputStream();5960sslOS.write(280);61sslOS.flush();62sslIS.read();6364SSLSession sslSession = socket.getSession();6566try {67sslSession.getValue(null);68} catch (IllegalArgumentException e) {69System.out.print("Caught proper exception: ");70System.out.println(e.getMessage());71}7273try {74sslSession.putValue(null, null);75} catch (IllegalArgumentException e) {76System.out.print("Caught proper exception: ");77System.out.println(e.getMessage());78}7980try {81sslSession.removeValue(null);82} catch (IllegalArgumentException e) {83System.out.print("Caught proper exception: ");84System.out.println(e.getMessage());85}8687String [] names = sslSession.getValueNames();88if ((names == null) || (names.length != 0)) {89throw new IOException(90"getValueNames didn't return 0-length arrary");91}92}9394public static void main(String[] args) throws Exception {95new SSLSessionNulls().run();96}97}9899100