2
|
1 |
/*
|
10328
|
2 |
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
|
2
|
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 |
*
|
5506
|
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.
|
2
|
22 |
*/
|
|
23 |
|
|
24 |
/**
|
|
25 |
* @test
|
|
26 |
* @bug 6449579
|
|
27 |
* @summary DefaultSSLServerSocketFactory does not override createServerSocket()
|
10328
|
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.
|
2
|
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 {
|
10328
|
40 |
// reserve the security properties
|
|
41 |
String reservedSSFacProvider =
|
|
42 |
Security.getProperty("ssl.ServerSocketFactory.provider");
|
|
43 |
|
2
|
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
|
10328
|
55 |
} finally {
|
|
56 |
// restore the security properties
|
|
57 |
if (reservedSSFacProvider == null) {
|
|
58 |
reservedSSFacProvider = "";
|
|
59 |
}
|
|
60 |
Security.setProperty("ssl.ServerSocketFactory.provider",
|
|
61 |
reservedSSFacProvider);
|
2
|
62 |
}
|
|
63 |
}
|
|
64 |
}
|