diff options
author | weijun <none@none> | 2013-03-23 11:49:39 +0800 |
---|---|---|
committer | weijun <none@none> | 2013-03-23 11:49:39 +0800 |
commit | 1caa673fa4afb11147f1988f3ca4d9f16b60778c (patch) | |
tree | c181670a9d42f790067dd205cbabaa18b14ab1cf /test/sun/security/krb5 | |
parent | dd98a9ba8fcd9d62a1cf8e7ef4c09dd27a28d881 (diff) |
8009875: Provide a default udp_preference_limit for krb5.conf
Reviewed-by: valeriep
Diffstat (limited to 'test/sun/security/krb5')
-rw-r--r-- | test/sun/security/krb5/auto/KDC.java | 10 | ||||
-rw-r--r-- | test/sun/security/krb5/config/DefUdpLimit.java | 67 |
2 files changed, 72 insertions, 5 deletions
diff --git a/test/sun/security/krb5/auto/KDC.java b/test/sun/security/krb5/auto/KDC.java index 83cafe73f..44330dfc7 100644 --- a/test/sun/security/krb5/auto/KDC.java +++ b/test/sun/security/krb5/auto/KDC.java @@ -923,29 +923,29 @@ public class KDC { pas2 = new DerValue[] { new DerValue(new ETypeInfo2(1, null, null).asn1Encode()), new DerValue(new ETypeInfo2(1, "", null).asn1Encode()), - new DerValue(new ETypeInfo2(1, OneKDC.REALM, new byte[]{1}).asn1Encode()), + new DerValue(new ETypeInfo2(1, realm, new byte[]{1}).asn1Encode()), }; pas = new DerValue[] { new DerValue(new ETypeInfo(1, null).asn1Encode()), new DerValue(new ETypeInfo(1, "").asn1Encode()), - new DerValue(new ETypeInfo(1, OneKDC.REALM).asn1Encode()), + new DerValue(new ETypeInfo(1, realm).asn1Encode()), }; break; case 2: // we still reject non-null s2kparams and prefer E2 over E pas2 = new DerValue[] { - new DerValue(new ETypeInfo2(1, OneKDC.REALM, new byte[]{1}).asn1Encode()), + new DerValue(new ETypeInfo2(1, realm, new byte[]{1}).asn1Encode()), new DerValue(new ETypeInfo2(1, null, null).asn1Encode()), new DerValue(new ETypeInfo2(1, "", null).asn1Encode()), }; pas = new DerValue[] { - new DerValue(new ETypeInfo(1, OneKDC.REALM).asn1Encode()), + new DerValue(new ETypeInfo(1, realm).asn1Encode()), new DerValue(new ETypeInfo(1, null).asn1Encode()), new DerValue(new ETypeInfo(1, "").asn1Encode()), }; break; case 3: // but only E is wrong pas = new DerValue[] { - new DerValue(new ETypeInfo(1, OneKDC.REALM).asn1Encode()), + new DerValue(new ETypeInfo(1, realm).asn1Encode()), new DerValue(new ETypeInfo(1, null).asn1Encode()), new DerValue(new ETypeInfo(1, "").asn1Encode()), }; diff --git a/test/sun/security/krb5/config/DefUdpLimit.java b/test/sun/security/krb5/config/DefUdpLimit.java new file mode 100644 index 000000000..ae1712d0b --- /dev/null +++ b/test/sun/security/krb5/config/DefUdpLimit.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2013, 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 8009875 + * @summary Provide a default udp_preference_limit for krb5.conf + * @compile -XDignore.symbol.file DefUdpLimit.java + * @run main/othervm DefUdpLimit -1 1465 + * @run main/othervm DefUdpLimit 0 0 + * @run main/othervm DefUdpLimit 1234 1234 + * @run main/othervm DefUdpLimit 12345 12345 + * @run main/othervm DefUdpLimit 123456 32700 + * + */ + +import sun.security.krb5.KdcComm; + +import java.lang.reflect.Field; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class DefUdpLimit { + + public static void main(String[] args) throws Exception { + int set = Integer.valueOf(args[0]); + int expected = Integer.valueOf(args[1]); + Field f = KdcComm.class.getDeclaredField("defaultUdpPrefLimit"); + f.setAccessible(true); + writeConf(set); + int actual = (Integer)f.get(null); + if (actual != expected) { + throw new Exception("Expected: " + expected + ", get " + actual); + } + } + + static void writeConf(int i) throws Exception { + String file = "krb5.conf." + i; + String content = "[libdefaults]\n"; + if (i >= 0) { + content += "udp_preference_limit = " + i; + } + Files.write(Paths.get(file), content.getBytes()); + System.setProperty("java.security.krb5.conf", file); + } +} + |