Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/com/sun/jndi/dns/ConfigTests/RecursiveTest.java
41155 views
1
/*
2
* Copyright (c) 2000, 2018, 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
import javax.naming.NamingException;
25
import javax.naming.directory.Attributes;
26
import javax.naming.directory.InitialDirContext;
27
import java.util.Hashtable;
28
29
/*
30
* @test
31
* @bug 8200151
32
* @summary Tests that we can get the attributes of DNS entries of
33
* nonrecursive data. And recursive data by default or when
34
* com.sun.jndi.dns.recursion is set to true, but not when
35
* com.sun.jndi.dns.recursion is set to false.
36
* @library ../lib/
37
* @modules java.base/sun.security.util
38
* @run main RecursiveTest -Dtestname=RecursiveDefault
39
* @run main RecursiveTest -Dtestname=RecursiveFalse
40
* @run main RecursiveTest -Dtestname=RecursiveTrue
41
*/
42
43
public class RecursiveTest extends AuthRecursiveBase {
44
45
public static void main(String[] args) throws Exception {
46
new RecursiveTest().run(args);
47
}
48
49
/*
50
* Tests that we can get the attributes of DNS entries of
51
* nonrecursive data. And recursive data by default or when
52
* com.sun.jndi.dns.recursion is set to true, but not when
53
* com.sun.jndi.dns.recursion is set to false.
54
*/
55
@Override
56
public void runTest() throws Exception {
57
String flag = parseFlagFromTestName();
58
59
if (flag.equalsIgnoreCase("default")) {
60
setContext(new InitialDirContext());
61
} else {
62
Hashtable<Object, Object> env = new Hashtable<>();
63
DNSTestUtils.debug("set com.sun.jndi.dns.recursion to " + flag);
64
// com.sun.jndi.dns.recursion is set to true or false
65
env.put("com.sun.jndi.dns.recursion", flag);
66
setContext(new InitialDirContext(env));
67
}
68
69
retrieveAndVerifyNonRecursiveData();
70
retrieveRecursiveData(
71
flag.equalsIgnoreCase("default") || Boolean.parseBoolean(flag));
72
}
73
74
private void retrieveAndVerifyNonRecursiveData() throws NamingException {
75
// Ensure that nonrecursive data retrieval is OK
76
retrieveAndVerifyData(getFqdnUrl());
77
}
78
79
/*
80
* If isRecur == true, ensure that recursive data retrieval is OK.
81
* If isRecur == false, ensure that recursive data retrieval fails.
82
*/
83
private void retrieveRecursiveData(boolean isRecur) throws NamingException {
84
Attributes retAttrs = context().getAttributes(getForeignFqdnUrl());
85
if (isRecur) {
86
DNSTestUtils.verifySchema(retAttrs, new String[] { "CNAME" },
87
new String[] {});
88
} else {
89
DNSTestUtils.debug(retAttrs);
90
if (retAttrs.size() > 0) {
91
throw new RuntimeException("Expecting recursive data not found "
92
+ getForeignFqdnUrl());
93
}
94
}
95
}
96
}
97
98