Krb5Conf.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 1999-2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
//
// Currently, the admin tool only needs to access all of the
// admin servers for all of the realms enumerated in the file,
// and the default realm.
// A sample file looks like this:
/*
[libdefaults]
default_realm = SUNSOFT.FOO.SUN.COM
[realms]
GENESIS.FOO.SUN.COM = {
kdc = xxxxx.eng.sun.com
admin_server = xxxxx.eng.sun.com
}
SUNSOFT.FOO.SUN.COM = {
kdc = gandolf.eng.sun.com
kdc = ulong.eng.sun.com
admin_server = gandolf.eng.sun.com:749
}
[domain_realm]
.eng.sun.com = SUNSOFT.FOO.SUN.COM
.sun.com = SUNSOFT.FOO.SUN.COM
[logging]
[appdefaults]
gkadmin = {
help_url = http:...
}
*/
public class Krb5Conf {
public Krb5Conf() {
try {
} catch (FileNotFoundException e) {
// System.out.println("Error: " + e);
return;
}
// Read each line of the file
do {
try {
} catch (IOException e) {
// System.out.println("Error: " + e);
return;
}
break;
// System.out.println(line);
// Get some help with parsing
if (!t.hasMoreTokens())
continue;
continue;
// Look for [realm], [libdefaults] or [appdefaults]
wantdef = false;
wantrealm = false;
wantapp = false;
wantdef = true;
wantrealm = true;
wantapp = true;
} else {
// Have we seen [libdefaults]?
if (t.hasMoreTokens()) {
wantdef = false;
}
// Have we seen [realm] instead?
} else if (wantrealm) {
// We got what we needed; skip until "{" is balanced
skipcurly = false;
continue;
}
// First the realm name, then the admin server
if (!wantadmin) {
wantadmin = true;
Server = "";
Port = "0";
} else {
s = t.nextToken(" \t\n\r=:");
if (t.hasMoreTokens()) {
s = t.nextToken(" \t\n\r=:");
}
// Store result in the vector
wantadmin = false;
skipcurly = true;
}
}
} else if (wantapp) {
if (t.hasMoreTokens()) {
wantapp = false;
wanturl = false;
}
wanturl = true;
}
}
}
public String getDefaultRealm() {
return DefRealm;
}
public String getHelpURL() {
return HelpURL;
}
public String getAllRealms() {
String s = "";
}
return s;
}
return r.AdminServer;
}
return null;
}
return r.ServerPort;
}
return null;
}
}
}
while (t.hasMoreTokens()) {
String s = c.getRealmServer(r);
String p = c.getRealmPort(r);
+ ", port is " + p);
}
}
}