Path: blob/master/test/jdk/javax/net/ssl/FixingJavadocs/SSLSessionNulls.java
41153 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* @modules jdk.crypto.ec30* @run main/othervm SSLSessionNulls31*32* SunJSSE does not support dynamic system properties, no way to re-use33* system properties in samevm/agentvm mode.34* @author Brad Wetmore35*/3637import java.io.IOException;38import java.io.InputStream;39import java.io.OutputStream;4041import javax.net.ssl.SSLSession;42import javax.net.ssl.SSLSocket;4344public class SSLSessionNulls extends SSLSocketTemplate {4546@Override47protected void runServerApplication(SSLSocket socket) throws Exception {48InputStream sslIS = socket.getInputStream();49OutputStream sslOS = socket.getOutputStream();5051sslIS.read();52sslOS.write(85);53sslOS.flush();54}5556@Override57protected void runClientApplication(SSLSocket socket) throws Exception {58InputStream sslIS = socket.getInputStream();59OutputStream sslOS = socket.getOutputStream();6061sslOS.write(280);62sslOS.flush();63sslIS.read();6465SSLSession sslSession = socket.getSession();6667try {68sslSession.getValue(null);69} catch (IllegalArgumentException e) {70System.out.print("Caught proper exception: ");71System.out.println(e.getMessage());72}7374try {75sslSession.putValue(null, null);76} catch (IllegalArgumentException e) {77System.out.print("Caught proper exception: ");78System.out.println(e.getMessage());79}8081try {82sslSession.removeValue(null);83} catch (IllegalArgumentException e) {84System.out.print("Caught proper exception: ");85System.out.println(e.getMessage());86}8788String [] names = sslSession.getValueNames();89if ((names == null) || (names.length != 0)) {90throw new IOException(91"getValueNames didn't return 0-length arrary");92}93}9495public static void main(String[] args) throws Exception {96new SSLSessionNulls().run();97}98}99100101