Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/net/ssl/SSLServerSocket/DefaultSSLServSocketFac.java
41152 views
1
/*
2
* Copyright (c) 2007, 2011, 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 6449579
27
* @summary DefaultSSLServerSocketFactory does not override createServerSocket()
28
* @run main/othervm DefaultSSLServSocketFac
29
*
30
* SunJSSE does not support dynamic system properties, no way to re-use
31
* system properties in samevm/agentvm mode.
32
*/
33
import java.security.Security;
34
import javax.net.ServerSocketFactory;
35
import javax.net.ssl.SSLServerSocket;
36
import javax.net.ssl.SSLServerSocketFactory;
37
38
public class DefaultSSLServSocketFac {
39
public static void main(String[] args) throws Exception {
40
// reserve the security properties
41
String reservedSSFacProvider =
42
Security.getProperty("ssl.ServerSocketFactory.provider");
43
44
try {
45
Security.setProperty("ssl.ServerSocketFactory.provider", "oops");
46
ServerSocketFactory ssocketFactory =
47
SSLServerSocketFactory.getDefault();
48
SSLServerSocket sslServerSocket =
49
(SSLServerSocket)ssocketFactory.createServerSocket();
50
} catch (Exception e) {
51
if (!(e.getCause() instanceof ClassNotFoundException)) {
52
throw e;
53
}
54
// get the expected exception
55
} finally {
56
// restore the security properties
57
if (reservedSSFacProvider == null) {
58
reservedSSFacProvider = "";
59
}
60
Security.setProperty("ssl.ServerSocketFactory.provider",
61
reservedSSFacProvider);
62
}
63
}
64
}
65
66