--- old/test/jdk/ProblemList.txt 2018-07-25 16:52:51.000000000 +0800 +++ new/test/jdk/ProblemList.txt 2018-07-25 16:52:50.000000000 +0800 @@ -863,6 +863,8 @@ com/sun/jndi/ldap/LdapTimeoutTest.java 8151678 linux-all +com/sun/jndi/dns/ConfigTests/PortUnreachable.java 7164518 macosx-all + javax/rmi/ssl/SSLSocketParametersTest.sh 8162906 generic-all ############################################################################ --- /dev/null 2018-07-25 16:52:52.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/AuthDefault.dns 2018-07-25 16:52:51.000000000 +0800 @@ -0,0 +1,100 @@ +# +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# Capture file for AuthDefault.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the AuthDefault application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: E5 2C 01 00 00 01 00 00 00 00 00 00 05 68 6F 73 .,...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 01 ... + + +# DNS Response + +0000: E5 2C 85 80 00 01 00 06 00 01 00 01 05 68 6F 73 .,...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 01 C0 0C 00 10 00 01 00 00 8C A0 00 15 14 ................ +0030: 41 20 76 65 72 79 20 70 6F 70 75 6C 61 72 20 68 A very popular h +0040: 6F 73 74 2E C0 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 12 00 14 05 72 65 ..............re +0090: 6C 61 79 05 74 65 78 61 73 02 75 73 00 C0 0C 00 lay.texas.us.... +00A0: 0F 00 01 00 00 8C A0 00 0F 00 0A 05 72 65 6C 61 ............rela +00B0: 79 04 6F 68 69 6F C0 99 C0 0C 00 01 00 01 00 01 y.ohio.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + +# DNS Request + +0000: 84 D9 01 00 00 01 00 00 00 00 00 00 06 73 75 6E .............sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 01 COM..... + + +# DNS Response + +0000: 84 D9 81 80 00 01 00 01 00 06 00 0C 06 73 75 6E .............sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 01 C0 0C 00 05 00 01 00 00 COM............. +0030: 2A 30 00 0E 0B 73 75 6E 77 65 62 2D 70 73 72 76 *0...sunweb-psrv +0040: C0 13 C0 13 00 02 00 01 00 00 2A 30 00 14 0A 64 ..........*0...d +0050: 6E 73 6D 61 73 74 65 72 35 06 6F 72 61 63 6C 65 nsmaster5.oracle +0060: C0 1F C0 13 00 02 00 01 00 00 2A 30 00 0D 0A 64 ..........*0...d +0070: 6E 73 6D 61 73 74 65 72 31 C0 59 C0 13 00 02 00 nsmaster1.Y..... +0080: 01 00 00 2A 30 00 0D 0A 64 6E 73 6D 61 73 74 65 ...*0...dnsmaste +0090: 72 33 C0 59 C0 13 00 02 00 01 00 00 2A 30 00 0D r3.Y........*0.. +00A0: 0A 64 6E 73 6D 61 73 74 65 72 32 C0 59 C0 13 00 .dnsmaster2.Y... +00B0: 02 00 01 00 00 2A 30 00 0D 0A 64 6E 73 6D 61 73 .....*0...dnsmas +00C0: 74 65 72 36 C0 59 C0 13 00 02 00 01 00 00 2A 30 ter6.Y........*0 +00D0: 00 0D 0A 64 6E 73 6D 61 73 74 65 72 34 C0 59 C0 ...dnsmaster4.Y. +00E0: 6E 00 01 00 01 00 00 2A 30 00 04 C0 87 52 04 C0 n......*0....R.. +00F0: 6E 00 1C 00 01 00 00 2A 30 00 10 26 06 B4 00 14 n......*0..&.... +0100: 00 01 80 4F FF FF FF FF FF 9F 99 C0 A0 00 01 00 ...O............ +0110: 01 00 00 2A 30 00 04 C0 87 52 14 C0 A0 00 1C 00 ...*0....R...... +0120: 01 00 00 2A 30 00 10 26 06 B4 00 14 00 03 12 4F ...*0..&.......O +0130: FF FF FF FF FF 9F 99 C0 B9 00 01 00 01 00 00 2A ...............* +0140: 30 00 04 C0 87 52 54 C0 B9 00 1C 00 01 00 00 2A 0....RT........* +0150: 30 00 10 26 06 B4 00 14 00 41 40 4F FF FF FF FF 0..&.....A@O.... +0160: FF 9F 99 C0 4E 00 01 00 01 00 00 2A 30 00 04 C0 ....N......*0... +0170: 87 52 46 C0 4E 00 1C 00 01 00 00 2A 30 00 10 26 .RF.N......*0..& +0180: 06 B4 00 14 00 42 40 4F FF FF FF FF FF 9F 99 C0 .....B@O........ +0190: D2 00 01 00 01 00 00 2A 30 00 04 C0 87 52 34 C0 .......*0....R4. +01A0: D2 00 1C 00 01 00 00 2A 30 00 10 26 06 B4 00 14 .......*0..&.... +01B0: 00 81 40 4F FF FF FF FF FF 9F 99 C0 87 00 01 00 ..@O............ +01C0: 01 00 00 2A 30 00 04 C0 87 52 24 C0 87 00 1C 00 ...*0....R$..... +01D0: 01 00 00 2A 30 00 10 26 06 B4 00 14 00 80 40 4F ...*0..&......@O +01E0: FF FF FF FF FF 9F 99 ....... + + --- /dev/null 2018-07-25 16:52:53.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/AuthDefault.java 2018-07-25 16:52:52.000000000 +0800 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8200151 + * @summary Tests that we can get the attributes of DNS entries for both + * authoritative data and nonauthoritative data by default. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main AuthDefault + */ + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; + +public class AuthDefault extends AuthRecursiveBase { + + public static void main(String[] args) throws Exception { + new AuthDefault().run(args); + } + + /* + * Tests that we can get the attributes of DNS entries for both + * authoritative data and nonauthoritative data by default. + */ + @Override public void runTest() throws Exception { + initContext(); + retrieveAndVerifyAuthData(); + retrieveNonAuthData(); + } + + private void retrieveAndVerifyAuthData() throws NamingException { + // Ensure that auth data retrieval is OK + retrieveAndVerifyData(getFqdnUrl(), new String[] { "*" }); + } + + private void retrieveNonAuthData() throws NamingException { + // Ensure that nonauth data retrieval is OK + Attributes retAttrs = context() + .getAttributes(getForeignFqdnUrl(), new String[] { "*" }); + DNSTestUtils.debug(retAttrs); + // Skip checking attributes for foreign; just successful operation + // is sufficient + } +} --- /dev/null 2018-07-25 16:52:54.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/AuthFalse.dns 2018-07-25 16:52:53.000000000 +0800 @@ -0,0 +1,100 @@ +# +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# Capture file for AuthFalse.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the AuthFalse application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: 1C 7E 01 00 00 01 00 00 00 00 00 00 05 68 6F 73 .............hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 01 ... + + +# DNS Response + +0000: 1C 7E 85 80 00 01 00 06 00 01 00 01 05 68 6F 73 .............hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 01 C0 0C 00 10 00 01 00 00 8C A0 00 15 14 ................ +0030: 41 20 76 65 72 79 20 70 6F 70 75 6C 61 72 20 68 A very popular h +0040: 6F 73 74 2E C0 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 12 00 14 05 72 65 ..............re +0090: 6C 61 79 05 74 65 78 61 73 02 75 73 00 C0 0C 00 lay.texas.us.... +00A0: 0F 00 01 00 00 8C A0 00 0F 00 0A 05 72 65 6C 61 ............rela +00B0: 79 04 6F 68 69 6F C0 99 C0 0C 00 01 00 01 00 01 y.ohio.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + +# DNS Request + +0000: E7 16 01 00 00 01 00 00 00 00 00 00 06 73 75 6E .............sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 01 COM..... + + +# DNS Response + +0000: E7 16 81 80 00 01 00 01 00 06 00 0C 06 73 75 6E .............sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 01 C0 0C 00 05 00 01 00 00 COM............. +0030: 2A 30 00 0E 0B 73 75 6E 77 65 62 2D 70 73 72 76 *0...sunweb-psrv +0040: C0 13 C0 13 00 02 00 01 00 00 2A 30 00 14 0A 64 ..........*0...d +0050: 6E 73 6D 61 73 74 65 72 33 06 6F 72 61 63 6C 65 nsmaster3.oracle +0060: C0 1F C0 13 00 02 00 01 00 00 2A 30 00 0D 0A 64 ..........*0...d +0070: 6E 73 6D 61 73 74 65 72 35 C0 59 C0 13 00 02 00 nsmaster5.Y..... +0080: 01 00 00 2A 30 00 0D 0A 64 6E 73 6D 61 73 74 65 ...*0...dnsmaste +0090: 72 32 C0 59 C0 13 00 02 00 01 00 00 2A 30 00 0D r2.Y........*0.. +00A0: 0A 64 6E 73 6D 61 73 74 65 72 31 C0 59 C0 13 00 .dnsmaster1.Y... +00B0: 02 00 01 00 00 2A 30 00 0D 0A 64 6E 73 6D 61 73 .....*0...dnsmas +00C0: 74 65 72 36 C0 59 C0 13 00 02 00 01 00 00 2A 30 ter6.Y........*0 +00D0: 00 0D 0A 64 6E 73 6D 61 73 74 65 72 34 C0 59 C0 ...dnsmaster4.Y. +00E0: 6E 00 01 00 01 00 00 2A 30 00 04 C0 87 52 46 C0 n......*0....RF. +00F0: 6E 00 1C 00 01 00 00 2A 30 00 10 26 06 B4 00 14 n......*0..&.... +0100: 00 42 40 4F FF FF FF FF FF 9F 99 C0 4E 00 01 00 .B@O........N... +0110: 01 00 00 2A 30 00 04 C0 87 52 24 C0 4E 00 1C 00 ...*0....R$.N... +0120: 01 00 00 2A 30 00 10 26 06 B4 00 14 00 80 40 4F ...*0..&......@O +0130: FF FF FF FF FF 9F 99 C0 A0 00 01 00 01 00 00 2A ...............* +0140: 30 00 04 C0 87 52 04 C0 A0 00 1C 00 01 00 00 2A 0....R.........* +0150: 30 00 10 26 06 B4 00 14 00 01 80 4F FF FF FF FF 0..&.......O.... +0160: FF 9F 99 C0 B9 00 01 00 01 00 00 2A 30 00 04 C0 ...........*0... +0170: 87 52 54 C0 B9 00 1C 00 01 00 00 2A 30 00 10 26 .RT........*0..& +0180: 06 B4 00 14 00 41 40 4F FF FF FF FF FF 9F 99 C0 .....A@O........ +0190: D2 00 01 00 01 00 00 2A 30 00 04 C0 87 52 34 C0 .......*0....R4. +01A0: D2 00 1C 00 01 00 00 2A 30 00 10 26 06 B4 00 14 .......*0..&.... +01B0: 00 81 40 4F FF FF FF FF FF 9F 99 C0 87 00 01 00 ..@O............ +01C0: 01 00 00 2A 30 00 04 C0 87 52 14 C0 87 00 1C 00 ...*0....R...... +01D0: 01 00 00 2A 30 00 10 26 06 B4 00 14 00 03 12 4F ...*0..&.......O +01E0: FF FF FF FF FF 9F 99 ....... + + --- /dev/null 2018-07-25 16:52:55.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/AuthFalse.java 2018-07-25 16:52:54.000000000 +0800 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8200151 + * @summary Tests that we can get the attributes of DNS entries for both + * authoritative data and nonauthoritative data when + * java.naming.authoritative is set to false. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main AuthFalse + */ + +import javax.naming.Context; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.InitialDirContext; +import java.util.Hashtable; + +public class AuthFalse extends AuthRecursiveBase { + + public static void main(String[] args) throws Exception { + new AuthFalse().run(args); + } + + /* + * Tests that we can get the attributes of DNS entries for both + * authoritative data and nonauthoritative data when + * java.naming.authoritative is set to false. + */ + @Override public void runTest() throws Exception { + initContext(); + retrieveAndVerifyAuthData(); + retrieveNonAuthData(); + } + + @Override public void initContext() throws Exception { + Hashtable env = new Hashtable<>(); + // java.naming.authoritative is set to false + env.put(Context.AUTHORITATIVE, "false"); + setContext(new InitialDirContext(env)); + } + + private void retrieveAndVerifyAuthData() throws NamingException { + // Ensure that auth data retrieval is OK + retrieveAndVerifyData(getFqdnUrl(), new String[] { "*" }); + } + + private void retrieveNonAuthData() throws NamingException { + // Ensure that nonauth data retrieval is OK + Attributes retAttrs = context() + .getAttributes(getForeignFqdnUrl(), new String[] { "*" }); + DNSTestUtils.debug(retAttrs); + // Skip checking attributes for foreign; just successful operation + // is sufficient + } +} --- /dev/null 2018-07-25 16:52:56.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/AuthRecursiveBase.java 2018-07-25 16:52:56.000000000 +0800 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.InitialDirContext; + +public abstract class AuthRecursiveBase extends DNSTestBase { + + private static final String KEY = "host1"; + private static final String[] MANDATORY_ATTRIBUTES = { "A", "MX", "HINFO", + "TXT", "29" }; + private static final String[] OPTIONAL_ATTRIBUTES = {}; + + private String fqdnUrl; + private String foreignFqdnUrl; + + @Override public void setupTest() { + super.setupTest(); + String fqdn = DNSTestUtils.buildFqdn(KEY, env(), true); + + String foreignLeaf = (String) env().get("FOREIGN_LEAF"); + String foreignFqdn = DNSTestUtils.buildFqdn(foreignLeaf, env(), false); + + fqdnUrl = DNSTestUtils.getRootUrl(env()) + "/" + fqdn; + foreignFqdnUrl = DNSTestUtils.getRootUrl(env()) + "/" + foreignFqdn; + } + + public void initContext() throws Exception { + setContext(new InitialDirContext()); + } + + public void retrieveAndVerifyData(String name) throws NamingException { + Attributes retAttrs = context().getAttributes(name); + DNSTestUtils.verifySchema(retAttrs, MANDATORY_ATTRIBUTES, + OPTIONAL_ATTRIBUTES); + } + + public void retrieveAndVerifyData(String name, String[] attrIds) + throws NamingException { + Attributes retAttrs = context().getAttributes(name, attrIds); + DNSTestUtils.verifySchema(retAttrs, MANDATORY_ATTRIBUTES, + OPTIONAL_ATTRIBUTES); + } + + public String getFqdnUrl() { + return fqdnUrl; + } + + public String getForeignFqdnUrl() { + return foreignFqdnUrl; + } +} --- /dev/null 2018-07-25 16:52:58.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/AuthTrue.dns 2018-07-25 16:52:58.000000000 +0800 @@ -0,0 +1,100 @@ +# +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# Capture file for AuthTrue.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the AuthTrue application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: 1E 74 01 00 00 01 00 00 00 00 00 00 05 68 6F 73 .t...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 01 ... + + +# DNS Response + +0000: 1E 74 85 80 00 01 00 06 00 01 00 01 05 68 6F 73 .t...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 01 C0 0C 00 10 00 01 00 00 8C A0 00 15 14 ................ +0030: 41 20 76 65 72 79 20 70 6F 70 75 6C 61 72 20 68 A very popular h +0040: 6F 73 74 2E C0 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 11 00 0A 05 72 65 ..............re +0090: 6C 61 79 04 6F 68 69 6F 02 75 73 00 C0 0C 00 0F lay.ohio.us..... +00A0: 00 01 00 00 8C A0 00 10 00 14 05 72 65 6C 61 79 ...........relay +00B0: 05 74 65 78 61 73 C0 98 C0 0C 00 01 00 01 00 01 .texas.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + +# DNS Request + +0000: 8C F4 01 00 00 01 00 00 00 00 00 00 06 73 75 6E .............sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 01 COM..... + + +# DNS Response + +0000: 8C F4 81 80 00 01 00 01 00 06 00 0C 06 73 75 6E .............sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 01 C0 0C 00 05 00 01 00 00 COM............. +0030: 25 8D 00 0E 0B 73 75 6E 77 65 62 2D 70 73 72 76 %....sunweb-psrv +0040: C0 13 C0 13 00 02 00 01 00 00 25 8D 00 14 0A 64 ..........%....d +0050: 6E 73 6D 61 73 74 65 72 33 06 6F 72 61 63 6C 65 nsmaster3.oracle +0060: C0 1F C0 13 00 02 00 01 00 00 25 8D 00 0D 0A 64 ..........%....d +0070: 6E 73 6D 61 73 74 65 72 34 C0 59 C0 13 00 02 00 nsmaster4.Y..... +0080: 01 00 00 25 8D 00 0D 0A 64 6E 73 6D 61 73 74 65 ...%....dnsmaste +0090: 72 31 C0 59 C0 13 00 02 00 01 00 00 25 8D 00 0D r1.Y........%... +00A0: 0A 64 6E 73 6D 61 73 74 65 72 32 C0 59 C0 13 00 .dnsmaster2.Y... +00B0: 02 00 01 00 00 25 8D 00 0D 0A 64 6E 73 6D 61 73 .....%....dnsmas +00C0: 74 65 72 36 C0 59 C0 13 00 02 00 01 00 00 25 8D ter6.Y........%. +00D0: 00 0D 0A 64 6E 73 6D 61 73 74 65 72 35 C0 59 C0 ...dnsmaster5.Y. +00E0: D2 00 01 00 01 00 00 25 8D 00 04 C0 87 52 46 C0 .......%.....RF. +00F0: D2 00 1C 00 01 00 00 25 8D 00 10 26 06 B4 00 14 .......%...&.... +0100: 00 42 40 4F FF FF FF FF FF 9F 99 C0 4E 00 01 00 .B@O........N... +0110: 01 00 00 25 8D 00 04 C0 87 52 24 C0 4E 00 1C 00 ...%.....R$.N... +0120: 01 00 00 25 8D 00 10 26 06 B4 00 14 00 80 40 4F ...%...&......@O +0130: FF FF FF FF FF 9F 99 C0 87 00 01 00 01 00 00 25 ...............% +0140: 8D 00 04 C0 87 52 04 C0 87 00 1C 00 01 00 00 25 .....R.........% +0150: 8D 00 10 26 06 B4 00 14 00 01 80 4F FF FF FF FF ...&.......O.... +0160: FF 9F 99 C0 B9 00 01 00 01 00 00 25 8D 00 04 C0 ...........%.... +0170: 87 52 54 C0 B9 00 1C 00 01 00 00 25 8D 00 10 26 .RT........%...& +0180: 06 B4 00 14 00 41 40 4F FF FF FF FF FF 9F 99 C0 .....A@O........ +0190: 6E 00 01 00 01 00 00 25 8D 00 04 C0 87 52 34 C0 n......%.....R4. +01A0: 6E 00 1C 00 01 00 00 25 8D 00 10 26 06 B4 00 14 n......%...&.... +01B0: 00 81 40 4F FF FF FF FF FF 9F 99 C0 A0 00 01 00 ..@O............ +01C0: 01 00 00 25 8D 00 04 C0 87 52 14 C0 A0 00 1C 00 ...%.....R...... +01D0: 01 00 00 25 8D 00 10 26 06 B4 00 14 00 03 12 4F ...%...&.......O +01E0: FF FF FF FF FF 9F 99 ....... + + --- /dev/null 2018-07-25 16:52:59.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/AuthTrue.java 2018-07-25 16:52:59.000000000 +0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8200151 + * @summary Tests that we can get the attributes of DNS entries + * authoritative data but not nonauthoritative data when + * java.naming.authoritative is set to true. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main AuthTrue + */ + +import javax.naming.Context; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.InitialDirContext; +import java.util.Hashtable; + +public class AuthTrue extends AuthRecursiveBase { + + public static void main(String[] args) throws Exception { + new AuthTrue().run(args); + } + + /* + * Tests that we can get the attributes of DNS entries + * authoritative data but not nonauthoritative data when + * java.naming.authoritative is set to true. + */ + @Override public void runTest() throws Exception { + initContext(); + retrieveAndVerifyAuthData(); + retrieveNonAuthData(); + } + + @Override public void initContext() throws Exception { + Hashtable env = new Hashtable<>(); + // java.naming.authoritative is set to true + env.put(Context.AUTHORITATIVE, "true"); + setContext(new InitialDirContext(env)); + } + + private void retrieveAndVerifyAuthData() throws NamingException { + // Ensure that auth data retrieval is OK + retrieveAndVerifyData(getFqdnUrl(), new String[] { "*" }); + } + + private void retrieveNonAuthData() throws NamingException { + try { + // Ensure that nonauth data retrieval cannot be retrieved + Attributes retAttrs = context() + .getAttributes(getForeignFqdnUrl(), new String[] { "*" }); + DNSTestUtils.debug(retAttrs); + throw new RuntimeException( + "Failed: Expecting nonauth entry not found " + + getForeignFqdnUrl()); + + } catch (NameNotFoundException e) { + System.out.println("Got exception as expected : " + e); + } + } +} --- /dev/null 2018-07-25 16:53:00.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/PortUnreachable.java 2018-07-25 16:53:00.000000000 +0800 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8200151 + * @summary Tests that when a DNS server is unreachable and an ICMP Destination + * Unreachable packet is received, we fail quickly and don't wait for + * the full timeout interval. This could be caused, for example, by a + * dead DNS server or a flakey router. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main PortUnreachable + */ + +import javax.naming.CommunicationException; +import javax.naming.Context; +import javax.naming.directory.DirContext; +import javax.naming.directory.InitialDirContext; +import java.util.Hashtable; + +public class PortUnreachable { + + // Port 25 is the SMTP port, used here to simulate a dead DNS server. + private static final int PORT = 25; + + public static void main(String[] args) throws Exception { + Hashtable env; + + // initialize test + env = DNSTestUtils.initEnv(false, PortUnreachable.class.getName(), args); + + String deadServerUrl = "dns://localhost:" + PORT; + + env.put(Context.PROVIDER_URL, deadServerUrl); + + DirContext ctx = null; + + try { + ctx = new InitialDirContext(env); + + // Any request should fail quickly. + long startTime = System.currentTimeMillis(); + try { + ctx.getAttributes(""); + } catch (CommunicationException e) { + + long elapsedTime = System.currentTimeMillis() - startTime; + + Throwable cause = e.getRootCause(); + if (cause == null + || !(cause instanceof java.net.PortUnreachableException)) { + DNSTestUtils + .debug("Bug 7164518 can cause this failure on mac"); + throw e; + } + + DNSTestUtils.debug("Elapsed (ms): " + elapsedTime); + + // Check that elapsed time is under a second. + if (elapsedTime < 1000) { + return; + } + + throw new RuntimeException( + "Failed: call took " + elapsedTime + " ms"); + } + + // You're running a DNS server on your SMTP port? + throw new RuntimeException( + "Failed: getAttributes succeeded unexpectedly"); + + } finally { + DNSTestUtils.cleanup(ctx); + } + } +} --- /dev/null 2018-07-25 16:53:01.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/RecursiveDefault.dns 2018-07-25 16:53:01.000000000 +0800 @@ -0,0 +1,100 @@ +# +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# Capture file for RecursiveDefault.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the RecursiveDefault application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: A9 3C 01 00 00 01 00 00 00 00 00 00 05 68 6F 73 .<...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 FF ... + + +# DNS Response + +0000: A9 3C 85 80 00 01 00 06 00 01 00 01 05 68 6F 73 .<...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 FF C0 0C 00 10 00 01 00 00 8C A0 00 15 14 ................ +0030: 41 20 76 65 72 79 20 70 6F 70 75 6C 61 72 20 68 A very popular h +0040: 6F 73 74 2E C0 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 11 00 0A 05 72 65 ..............re +0090: 6C 61 79 04 6F 68 69 6F 02 75 73 00 C0 0C 00 0F lay.ohio.us..... +00A0: 00 01 00 00 8C A0 00 10 00 14 05 72 65 6C 61 79 ...........relay +00B0: 05 74 65 78 61 73 C0 98 C0 0C 00 01 00 01 00 01 .texas.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + +# DNS Request + +0000: 87 6D 01 00 00 01 00 00 00 00 00 00 06 73 75 6E .m...........sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 FF COM..... + + +# DNS Response + +0000: 87 6D 81 80 00 01 00 01 00 06 00 0C 06 73 75 6E .m...........sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 FF C0 0C 00 05 00 01 00 00 COM............. +0030: 1C 50 00 0E 0B 73 75 6E 77 65 62 2D 70 73 72 76 .P...sunweb-psrv +0040: C0 13 C0 13 00 02 00 01 00 00 1C 50 00 14 0A 64 ...........P...d +0050: 6E 73 6D 61 73 74 65 72 32 06 6F 72 61 63 6C 65 nsmaster2.oracle +0060: C0 1F C0 13 00 02 00 01 00 00 1C 50 00 0D 0A 64 ...........P...d +0070: 6E 73 6D 61 73 74 65 72 34 C0 59 C0 13 00 02 00 nsmaster4.Y..... +0080: 01 00 00 1C 50 00 0D 0A 64 6E 73 6D 61 73 74 65 ....P...dnsmaste +0090: 72 35 C0 59 C0 13 00 02 00 01 00 00 1C 50 00 0D r5.Y.........P.. +00A0: 0A 64 6E 73 6D 61 73 74 65 72 33 C0 59 C0 13 00 .dnsmaster3.Y... +00B0: 02 00 01 00 00 1C 50 00 0D 0A 64 6E 73 6D 61 73 ......P...dnsmas +00C0: 74 65 72 31 C0 59 C0 13 00 02 00 01 00 00 1C 50 ter1.Y.........P +00D0: 00 0D 0A 64 6E 73 6D 61 73 74 65 72 36 C0 59 C0 ...dnsmaster6.Y. +00E0: B9 00 01 00 01 00 00 1C 50 00 04 C0 87 52 04 C0 ........P....R.. +00F0: B9 00 1C 00 01 00 00 1C 50 00 10 26 06 B4 00 14 ........P..&.... +0100: 00 01 80 4F FF FF FF FF FF 9F 99 C0 4E 00 01 00 ...O........N... +0110: 01 00 00 1C 50 00 04 C0 87 52 14 C0 4E 00 1C 00 ....P....R..N... +0120: 01 00 00 1C 50 00 10 26 06 B4 00 14 00 03 12 4F ....P..&.......O +0130: FF FF FF FF FF 9F 99 C0 D2 00 01 00 01 00 00 1C ................ +0140: 50 00 04 C0 87 52 54 C0 D2 00 1C 00 01 00 00 1C P....RT......... +0150: 50 00 10 26 06 B4 00 14 00 41 40 4F FF FF FF FF P..&.....A@O.... +0160: FF 9F 99 C0 87 00 01 00 01 00 00 1C 50 00 04 C0 ............P... +0170: 87 52 46 C0 87 00 1C 00 01 00 00 1C 50 00 10 26 .RF.........P..& +0180: 06 B4 00 14 00 42 40 4F FF FF FF FF FF 9F 99 C0 .....B@O........ +0190: 6E 00 01 00 01 00 00 1C 50 00 04 C0 87 52 34 C0 n.......P....R4. +01A0: 6E 00 1C 00 01 00 00 1C 50 00 10 26 06 B4 00 14 n.......P..&.... +01B0: 00 81 40 4F FF FF FF FF FF 9F 99 C0 A0 00 01 00 ..@O............ +01C0: 01 00 00 1C 50 00 04 C0 87 52 24 C0 A0 00 1C 00 ....P....R$..... +01D0: 01 00 00 1C 50 00 10 26 06 B4 00 14 00 80 40 4F ....P..&......@O +01E0: FF FF FF FF FF 9F 99 ....... + + --- /dev/null 2018-07-25 16:53:02.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/RecursiveDefault.java 2018-07-25 16:53:02.000000000 +0800 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8200151 + * @summary Tests that we can get the attributes of DNS entries for both + * recursive data and nonrecursive data by default. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main RecursiveDefault + */ + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; + +public class RecursiveDefault extends AuthRecursiveBase { + + public static void main(String[] args) throws Exception { + new RecursiveDefault().run(args); + } + + /* + * Tests that we can get the attributes of DNS entries for both + * recursive data and nonrecursive data by default. + */ + @Override public void runTest() throws Exception { + initContext(); + retrieveAndVerifyNonRecursiveData(); + retrieveRecursiveData(); + } + + private void retrieveAndVerifyNonRecursiveData() throws NamingException { + // Ensure that nonrecursive data retrieval is OK + retrieveAndVerifyData(getFqdnUrl()); + } + + private void retrieveRecursiveData() throws NamingException { + // Ensure that recursive data retrieval is OK + Attributes retAttrs = context().getAttributes(getForeignFqdnUrl()); + DNSTestUtils.verifySchema(retAttrs, new String[] { "CNAME" }, + new String[] {}); + } +} --- /dev/null 2018-07-25 16:53:03.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/RecursiveFalse.dns 2018-07-25 16:53:03.000000000 +0800 @@ -0,0 +1,76 @@ +# +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# Capture file for RecursiveFalse.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the RecursiveFalse application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: 55 B1 00 00 00 01 00 00 00 00 00 00 05 68 6F 73 U............hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 FF ... + + +# DNS Response + +0000: 55 B1 84 80 00 01 00 06 00 01 00 01 05 68 6F 73 U............hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 FF C0 0C 00 10 00 01 00 00 8C A0 00 15 14 ................ +0030: 41 20 76 65 72 79 20 70 6F 70 75 6C 61 72 20 68 A very popular h +0040: 6F 73 74 2E C0 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 12 00 14 05 72 65 ..............re +0090: 6C 61 79 05 74 65 78 61 73 02 75 73 00 C0 0C 00 lay.texas.us.... +00A0: 0F 00 01 00 00 8C A0 00 0F 00 0A 05 72 65 6C 61 ............rela +00B0: 79 04 6F 68 69 6F C0 99 C0 0C 00 01 00 01 00 01 y.ohio.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + +# DNS Request + +0000: 97 49 00 00 00 01 00 00 00 00 00 00 06 73 75 6E .I...........sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 FF COM..... + + +# DNS Response + +0000: 97 49 80 80 00 01 00 00 00 03 00 00 06 73 75 6E .I...........sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 FF 00 00 02 00 01 05 F5 E0 COM............. +0030: FF 00 0E 07 65 6E 67 64 6E 73 33 03 45 6E 67 C0 ....engdns3.Eng. +0040: 1B 00 00 02 00 01 05 F5 E0 FF 00 07 04 64 6E 73 .............dns +0050: 31 C0 3B 00 00 02 00 01 05 F5 E0 FF 00 0A 07 65 1.;............e +0060: 6E 67 64 6E 73 32 C0 3B ngdns2.; + + --- /dev/null 2018-07-25 16:53:04.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/RecursiveFalse.java 2018-07-25 16:53:04.000000000 +0800 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8200151 + * @summary Tests that we can get the attributes of DNS entries of + * nonrecursive data but not those of recursive data when + * com.sun.jndi.dns.recursion is set to false. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main RecursiveFalse + */ + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.InitialDirContext; +import java.util.Hashtable; + +public class RecursiveFalse extends AuthRecursiveBase { + + public static void main(String[] args) throws Exception { + new RecursiveFalse().run(args); + } + + /* + * Tests that we can get the attributes of DNS entries of + * nonrecursive data but not those of recursive data when + * com.sun.jndi.dns.recursion is set to false. + */ + @Override public void runTest() throws Exception { + initContext(); + retrieveAndVerifyNonRecursiveData(); + retrieveRecursiveData(); + } + + @Override public void initContext() throws Exception { + Hashtable env = new Hashtable<>(); + env.put("com.sun.jndi.dns.recursion", "false"); + setContext(new InitialDirContext(env)); + } + + private void retrieveAndVerifyNonRecursiveData() throws NamingException { + // Ensure that nonrecursive data retrieval is OK + retrieveAndVerifyData(getFqdnUrl()); + } + + private void retrieveRecursiveData() throws NamingException { + // Ensure that recursive data retrieval fails + Attributes retAttrs = context().getAttributes(getForeignFqdnUrl()); + DNSTestUtils.debug(retAttrs); + if (retAttrs.size() > 0) { + throw new RuntimeException( + "Failed: Expecting recursive data not found " + + getForeignFqdnUrl()); + } + } +} --- /dev/null 2018-07-25 16:53:05.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/RecursiveTrue.dns 2018-07-25 16:53:05.000000000 +0800 @@ -0,0 +1,100 @@ +# +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# Capture file for RecursiveTrue.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the RecursiveTrue application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: EA B1 01 00 00 01 00 00 00 00 00 00 05 68 6F 73 .............hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 FF ... + + +# DNS Response + +0000: EA B1 85 80 00 01 00 06 00 01 00 01 05 68 6F 73 .............hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 FF C0 0C 00 10 00 01 00 00 8C A0 00 15 14 ................ +0030: 41 20 76 65 72 79 20 70 6F 70 75 6C 61 72 20 68 A very popular h +0040: 6F 73 74 2E C0 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 12 00 14 05 72 65 ..............re +0090: 6C 61 79 05 74 65 78 61 73 02 75 73 00 C0 0C 00 lay.texas.us.... +00A0: 0F 00 01 00 00 8C A0 00 0F 00 0A 05 72 65 6C 61 ............rela +00B0: 79 04 6F 68 69 6F C0 99 C0 0C 00 01 00 01 00 01 y.ohio.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + +# DNS Request + +0000: 07 E5 01 00 00 01 00 00 00 00 00 00 06 73 75 6E .............sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 FF COM..... + + +# DNS Response + +0000: 07 E5 81 80 00 01 00 01 00 06 00 0C 06 73 75 6E .............sun +0010: 77 65 62 07 43 65 6E 74 72 61 6C 03 53 75 6E 03 web.Central.Sun. +0020: 43 4F 4D 00 00 FF 00 FF C0 0C 00 05 00 01 00 00 COM............. +0030: 15 7B 00 0E 0B 73 75 6E 77 65 62 2D 70 73 72 76 .....sunweb-psrv +0040: C0 13 C0 13 00 02 00 01 00 00 15 7B 00 14 0A 64 ...............d +0050: 6E 73 6D 61 73 74 65 72 31 06 6F 72 61 63 6C 65 nsmaster1.oracle +0060: C0 1F C0 13 00 02 00 01 00 00 15 7B 00 0D 0A 64 ...............d +0070: 6E 73 6D 61 73 74 65 72 33 C0 59 C0 13 00 02 00 nsmaster3.Y..... +0080: 01 00 00 15 7B 00 0D 0A 64 6E 73 6D 61 73 74 65 ........dnsmaste +0090: 72 34 C0 59 C0 13 00 02 00 01 00 00 15 7B 00 0D r4.Y............ +00A0: 0A 64 6E 73 6D 61 73 74 65 72 35 C0 59 C0 13 00 .dnsmaster5.Y... +00B0: 02 00 01 00 00 15 7B 00 0D 0A 64 6E 73 6D 61 73 ..........dnsmas +00C0: 74 65 72 36 C0 59 C0 13 00 02 00 01 00 00 15 7B ter6.Y.......... +00D0: 00 0D 0A 64 6E 73 6D 61 73 74 65 72 32 C0 59 C0 ...dnsmaster2.Y. +00E0: 4E 00 01 00 01 00 00 15 7B 00 04 C0 87 52 04 C0 N............R.. +00F0: 4E 00 1C 00 01 00 00 15 7B 00 10 26 06 B4 00 14 N..........&.... +0100: 00 01 80 4F FF FF FF FF FF 9F 99 C0 D2 00 01 00 ...O............ +0110: 01 00 00 15 7B 00 04 C0 87 52 14 C0 D2 00 1C 00 .........R...... +0120: 01 00 00 15 7B 00 10 26 06 B4 00 14 00 03 12 4F .......&.......O +0130: FF FF FF FF FF 9F 99 C0 B9 00 01 00 01 00 00 15 ................ +0140: 7B 00 04 C0 87 52 54 C0 B9 00 1C 00 01 00 00 15 .....RT......... +0150: 7B 00 10 26 06 B4 00 14 00 41 40 4F FF FF FF FF ...&.....A@O.... +0160: FF 9F 99 C0 A0 00 01 00 01 00 00 15 7B 00 04 C0 ................ +0170: 87 52 46 C0 A0 00 1C 00 01 00 00 15 7B 00 10 26 .RF............& +0180: 06 B4 00 14 00 42 40 4F FF FF FF FF FF 9F 99 C0 .....B@O........ +0190: 87 00 01 00 01 00 00 15 7B 00 04 C0 87 52 34 C0 .............R4. +01A0: 87 00 1C 00 01 00 00 15 7B 00 10 26 06 B4 00 14 ...........&.... +01B0: 00 81 40 4F FF FF FF FF FF 9F 99 C0 6E 00 01 00 ..@O........n... +01C0: 01 00 00 15 7B 00 04 C0 87 52 24 C0 6E 00 1C 00 .........R$.n... +01D0: 01 00 00 15 7B 00 10 26 06 B4 00 14 00 80 40 4F .......&......@O +01E0: FF FF FF FF FF 9F 99 ....... + + --- /dev/null 2018-07-25 16:53:06.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/RecursiveTrue.java 2018-07-25 16:53:06.000000000 +0800 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8200151 + * @summary Tests that we can get the attributes of DNS entries for both + * recursive data and nonrecursive data when the + * com.sun.jndi.dns.recursion property has been set to true. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main RecursiveTrue + */ + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.InitialDirContext; +import java.util.Hashtable; + +public class RecursiveTrue extends AuthRecursiveBase { + + public static void main(String[] args) throws Exception { + new RecursiveTrue().run(args); + } + + /* + * Tests that we can get the attributes of DNS entries for both + * recursive data and nonrecursive data when the + * com.sun.jndi.dns.recursion property has been set to true. + */ + @Override public void runTest() throws Exception { + initContext(); + retrieveAndVerifyNonRecursiveData(); + retrieveRecursiveData(); + } + + @Override public void initContext() throws Exception { + Hashtable env = new Hashtable<>(); + env.put("com.sun.jndi.dns.recursion", "true"); + setContext(new InitialDirContext(env)); + } + + private void retrieveAndVerifyNonRecursiveData() throws NamingException { + // Ensure that nonrecursive data retrieval is OK + retrieveAndVerifyData(getFqdnUrl()); + } + + private void retrieveRecursiveData() throws NamingException { + // Ensure that recursive data retrieval is OK + Attributes retAttrs = context().getAttributes(getForeignFqdnUrl()); + DNSTestUtils.verifySchema(retAttrs, new String[] { "CNAME" }, + new String[] {}); + } +} --- /dev/null 2018-07-25 16:53:07.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/ConfigTests/Timeout.java 2018-07-25 16:53:07.000000000 +0800 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8200151 + * @summary Tests that we can set the initial UDP timeout interval + * and the number of retries. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main Timeout + */ + +import javax.naming.CommunicationException; +import javax.naming.Context; +import javax.naming.directory.DirContext; +import javax.naming.directory.InitialDirContext; +import java.net.SocketTimeoutException; +import java.util.Hashtable; + +public class Timeout { + // Host 10.0.0.0 is a bit bucket, used here to simulate a DNS server that + // doesn't respond. 10.0.0.0 server shouldn't be reachable. + // Ping to this address should not give any reply + private static final String HOST = "10.0.0.0"; + // Port 9 is a bit bucket, used here to simulate a DNS server that + // doesn't respond. + private static final int PORT = 9; + + public static void main(String[] args) throws Exception { + Hashtable env; + + // initialize test + env = DNSTestUtils.initEnv(false, Timeout.class.getName(), args); + + String allQuietUrl = "dns://" + HOST + ":" + PORT; + + int timeout = 250; // initial timeout = 1/4 sec + int retries = 5; // try 5 times per server + + env.put(Context.PROVIDER_URL, allQuietUrl); + env.put("com.sun.jndi.dns.timeout.initial", "" + timeout); + env.put("com.sun.jndi.dns.timeout.retries", "" + retries); + + DirContext ctx = null; + + try { + ctx = new InitialDirContext(env); + + // Any request should fail after timeouts have expired. + long startTime = System.currentTimeMillis(); + try { + ctx.getAttributes(""); + } catch (CommunicationException e) { + + long elapsedTime = System.currentTimeMillis() - startTime; + if (!(e.getRootCause() instanceof SocketTimeoutException)) { + throw e; + } + + long expectedTime = timeout * ((1 << retries) - 1); + DNSTestUtils.debug("Elapsed (ms): " + elapsedTime); + DNSTestUtils.debug("Expected (ms): " + expectedTime); + + // Check that elapsed time is as long as expected, and + // not more than 50% greater. + if (elapsedTime >= expectedTime + && elapsedTime * 2 <= expectedTime * 3) { + System.out.println("elapsed time is as long as expected."); + return; + } + throw new RuntimeException( + "Failed: timeout in " + elapsedTime + " ms, expected" + + expectedTime + "ms"); + } + + throw new RuntimeException( + "Failed: getAttributes succeeded unexpectedly"); + + } finally { + DNSTestUtils.cleanup(ctx); + } + } +}