Methods Summary |
---|
public java.lang.String | getHome(java.lang.String user)Return an absolute pathname to the home directory for the specified user.
return ((String) homes.get(user));
|
public UserConfig | getUserConfig()Return the UserConfig listener with which we are associated.
// ----------------------------------------------------------- Properties
return (this.userConfig);
|
public java.util.Enumeration | getUsers()Return an enumeration of the usernames defined on this server.
return (homes.keys());
|
private void | init()Initialize our set of users and home directories.
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(PASSWORD_FILE));
while (true) {
// Accumulate the next line
StringBuffer buffer = new StringBuffer();
while (true) {
int ch = reader.read();
if ((ch < 0) || (ch == '\n"))
break;
buffer.append((char) ch);
}
String line = buffer.toString();
if (line.length() < 1)
break;
// Parse the line into constituent elements
int n = 0;
String tokens[] = new String[7];
for (int i = 0; i < tokens.length; i++)
tokens[i] = null;
while (n < tokens.length) {
String token = null;
int colon = line.indexOf(':");
if (colon >= 0) {
token = line.substring(0, colon);
line = line.substring(colon + 1);
} else {
token = line;
line = "";
}
tokens[n++] = token;
}
// Add this user and corresponding directory
if ((tokens[0] != null) && (tokens[5] != null))
homes.put(tokens[0], tokens[5]);
}
reader.close();
reader = null;
} catch (Exception e) {
if (reader != null) {
try {
reader.close();
} catch (IOException f) {
;
}
reader = null;
}
}
|
public void | setUserConfig(UserConfig userConfig)Set the UserConfig listener with which we are associated.
this.userConfig = userConfig;
init();
|