*/
private static String[] parseCapaths(String cRealm, String sRealm) throws KrbException {
String[] retList = null;
Config cfg = null;
try {
cfg = Config.getInstance();
} catch (Exception exc) {
if (DEBUG) {
System.out.println ("Configuration information can not be " +
"obtained " + exc.getMessage());
}
return null;
}
String intermediaries = cfg.getDefault(sRealm, cRealm);
if (intermediaries == null) {
if (DEBUG) {
System.out.println(">>> Realm parseCapaths: no cfg entry");
}
return null;
}
String tempTarget = null, tempRealm = null;
StringTokenizer strTok = null;
Stack<String> iStack = new Stack<String> ();
/*
* I don't expect any more than a handful of intermediaries.
*/
Vector<String> tempList = new Vector<String> (8, 8);
/*
* The initiator at first location.
*/
tempList.add(cRealm);
int count = 0; // For debug only
if (DEBUG) {
tempTarget = sRealm;
}
do {
if (DEBUG) {
count++;
System.out.println(">>> Realm parseCapaths: loop " +
count + ": target=" + tempTarget);
}
if (intermediaries != null &&
!intermediaries.equals(PrincipalName.REALM_COMPONENT_SEPARATOR_STR))
{
if (DEBUG) {
System.out.println(">>> Realm parseCapaths: loop " +
count + ": intermediaries=[" +
intermediaries + "]");
}
/*
* We have one or more space-separated intermediary realms.
* Stack them.
*/
strTok = new StringTokenizer(intermediaries, " ");
while (strTok.hasMoreTokens())
{
tempRealm = strTok.nextToken();
if (!tempRealm.equals(PrincipalName.
REALM_COMPONENT_SEPARATOR_STR) &&
!iStack.contains(tempRealm)) {
iStack.push(tempRealm);
if (DEBUG) {
System.out.println(">>> Realm parseCapaths: loop " +
count +
": pushed realm on to stack: " +
tempRealm);
}
} else if (DEBUG) {
System.out.println(">>> Realm parseCapaths: loop " +
count +
": ignoring realm: [" +
tempRealm + "]");
}
}
} else if (DEBUG) {
System.out.println(">>> Realm parseCapaths: loop " +
count +
": no intermediaries");
}
/*
* Get next intermediary realm from the stack
*/
try {
tempTarget = iStack.pop();
} catch (EmptyStackException exc) {
tempTarget = null;
}
if (tempTarget == null) {
/*
* No more intermediaries. We're done.
*/
break;
}
tempList.add(tempTarget);
if (DEBUG) {
System.out.println(">>> Realm parseCapaths: loop " + count +
": added intermediary to list: " +
tempTarget);
}
intermediaries = cfg.getDefault(tempTarget, cRealm);
} while (true);
retList = new String[tempList.size()];
try {