Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/net/ssl/FixingJavadocs/SSLSessionNulls.java
41153 views
1
/*
2
* Copyright (c) 2001, 2017, 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
* @test
26
* @bug 4387882
27
* @summary Need to revisit the javadocs for JSSE, especially the
28
* promoted classes.
29
* @library /javax/net/ssl/templates
30
* @modules jdk.crypto.ec
31
* @run main/othervm SSLSessionNulls
32
*
33
* SunJSSE does not support dynamic system properties, no way to re-use
34
* system properties in samevm/agentvm mode.
35
* @author Brad Wetmore
36
*/
37
38
import java.io.IOException;
39
import java.io.InputStream;
40
import java.io.OutputStream;
41
42
import javax.net.ssl.SSLSession;
43
import javax.net.ssl.SSLSocket;
44
45
public class SSLSessionNulls extends SSLSocketTemplate {
46
47
@Override
48
protected void runServerApplication(SSLSocket socket) throws Exception {
49
InputStream sslIS = socket.getInputStream();
50
OutputStream sslOS = socket.getOutputStream();
51
52
sslIS.read();
53
sslOS.write(85);
54
sslOS.flush();
55
}
56
57
@Override
58
protected void runClientApplication(SSLSocket socket) throws Exception {
59
InputStream sslIS = socket.getInputStream();
60
OutputStream sslOS = socket.getOutputStream();
61
62
sslOS.write(280);
63
sslOS.flush();
64
sslIS.read();
65
66
SSLSession sslSession = socket.getSession();
67
68
try {
69
sslSession.getValue(null);
70
} catch (IllegalArgumentException e) {
71
System.out.print("Caught proper exception: ");
72
System.out.println(e.getMessage());
73
}
74
75
try {
76
sslSession.putValue(null, null);
77
} catch (IllegalArgumentException e) {
78
System.out.print("Caught proper exception: ");
79
System.out.println(e.getMessage());
80
}
81
82
try {
83
sslSession.removeValue(null);
84
} catch (IllegalArgumentException e) {
85
System.out.print("Caught proper exception: ");
86
System.out.println(e.getMessage());
87
}
88
89
String [] names = sslSession.getValueNames();
90
if ((names == null) || (names.length != 0)) {
91
throw new IOException(
92
"getValueNames didn't return 0-length arrary");
93
}
94
}
95
96
public static void main(String[] args) throws Exception {
97
new SSLSessionNulls().run();
98
}
99
}
100
101