From 5b3a1ff4dfa4ac8a39bf441626a04b9a26eb7b34 Mon Sep 17 00:00:00 2001 From: weijun Date: Mon, 28 Mar 2011 18:04:10 +0800 Subject: [PATCH] 7019384: Realm.getRealmsList returns realms list in wrong (reverse) order Reviewed-by: xuelei --- .../classes/sun/security/krb5/Realm.java | 32 +++++++++---------- test/sun/security/krb5/ParseCAPaths.java | 22 ++++++++----- test/sun/security/krb5/krb5-capaths.conf | 10 ++++++ 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/share/classes/sun/security/krb5/Realm.java b/src/share/classes/sun/security/krb5/Realm.java index f7b450ec6..f148f8680 100644 --- a/src/share/classes/sun/security/krb5/Realm.java +++ b/src/share/classes/sun/security/krb5/Realm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2011, 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 @@ -362,19 +362,15 @@ public class Realm implements Cloneable { Stack iStack = new Stack<>(); /* - * I don't expect any more than a handful of intermediaries. + * The half-established reversed-path, starting from the final target + * (sRealm), each item can be connected to by the next one. + * Might contains wrong item, if found, a bad track is performed */ Vector tempList = new Vector<>(8, 8); - - /* - * The initiator at first location. - */ - tempList.add(cRealm); + tempList.add(sRealm); int count = 0; // For debug only - if (DEBUG) { - tempTarget = sRealm; - } + tempTarget = sRealm; out: do { if (DEBUG) { @@ -384,8 +380,8 @@ public class Realm implements Cloneable { } if (intermediaries != null && - !intermediaries.equals(PrincipalName.REALM_COMPONENT_SEPARATOR_STR)) - { + !intermediaries.equals(".") && + !intermediaries.equals(cRealm)) { if (DEBUG) { System.out.println(">>> Realm parseCapaths: loop " + count + ": intermediaries=[" + @@ -466,11 +462,15 @@ public class Realm implements Cloneable { } while (true); + if (tempList.isEmpty()) { + return null; + } + + // From (SREALM, T1, T2) to (CREALM, T2, T1) retList = new String[tempList.size()]; - try { - retList = tempList.toArray(retList); - } catch (ArrayStoreException exc) { - retList = null; + retList[0] = cRealm; + for (int i=1; i " + to); diff --git a/test/sun/security/krb5/krb5-capaths.conf b/test/sun/security/krb5/krb5-capaths.conf index db672820b..eead02c0b 100644 --- a/test/sun/security/krb5/krb5-capaths.conf +++ b/test/sun/security/krb5/krb5-capaths.conf @@ -85,3 +85,13 @@ I1.COM = { I3.COM = I2.COM I4.COM = I2.COM I5.COM } + +J1.COM = { + J2.COM=J1.COM +} + +A9.PRAGUE.XXX.CZ = { + PRAGUE.XXX.CZ = . + ROOT.XXX.CZ = PRAGUE.XXX.CZ + SERVIS.XXX.CZ = ROOT.XXX.CZ +} -- GitLab