Methods Summary |
---|
public void | addUser(org.gudy.azureus2.ui.console.UserProfile user)adds another user to the users list
usersMap.put( user.getUsername().toLowerCase(), user );
|
public org.gudy.azureus2.ui.console.UserProfile | authenticate(java.lang.String username, java.lang.String password)attempts to locate a user with the specified username and then
verifies that the specified password is the same as the password
associated with that user
UserProfile profile = getUser(username);
if( profile != null)
{
if( profile.authenticate( password ) )
return profile;
}
return null;
|
public void | deleteUser(java.lang.String userName)removes the user with the specified name
usersMap.remove(userName.toLowerCase());
|
protected void | doLoad(java.io.InputStream in)
XMLDecoder decoder = new XMLDecoder( in );
UserManagerConfig managerConfig = (UserManagerConfig)decoder.readObject();
for (Iterator iter = managerConfig.getUsers().iterator(); iter.hasNext();) {
UserProfile user = (UserProfile) iter.next();
usersMap.put(user.getUsername().toLowerCase(), user);
}
System.out.println("UserManager: registered " + usersMap.size() + " users");
decoder.close();
|
protected void | doSave(java.io.OutputStream out)
UserManagerConfig config = new UserManagerConfig();
List users = new ArrayList( usersMap.values() );
config.setUsers(users);
XMLEncoder encoder = new XMLEncoder( new BufferedOutputStream( out ) );
encoder.writeObject(config);
encoder.close();
|
public static org.gudy.azureus2.ui.console.multiuser.UserManager | getInstance(org.gudy.azureus2.plugins.PluginInterface pi)
if( instance == null )
{
String azureusUserDir = pi.getUtilities().getAzureusUserDir();
File dbFile = new File(azureusUserDir, USER_DB_CONFIG_FILE);
try {
instance = new UserManager(dbFile.getCanonicalPath());
if( dbFile.exists() )
{
System.out.println("loading user configuration from: " + dbFile.getCanonicalPath());
instance.load();
}
else
{
System.out.println("file: " + dbFile.getCanonicalPath() + " does not exist. using 'null' user manager");
}
} catch (IOException e)
{
throw new AzureusCoreException("Unable to instantiate default user manager");
}
}
return instance;
|
public org.gudy.azureus2.ui.console.UserProfile | getUser(java.lang.String username)returns the profile for the user with the specified username
otherwise null if there is no such user
return (UserProfile) usersMap.get(username.toLowerCase());
|
public java.util.Collection | getUsers()
return Collections.unmodifiableCollection(usersMap.values());
|
public void | load()load a new UserManager object from the specified input stream.
The input stream should contain an XML document as encoded by the
save() method
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fileName));
doLoad( bis );
|
public void | save()write the UserManager configuration out to the specified output stream.
the configuration is stored in XML format as specified by the XMLEncoder class
OutputStream out = new FileOutputStream(fileName);
doSave(out);
|