Search in sources :

Example 1 with UserManagerConfig

use of com.biglybt.ui.console.multiuser.UserManager.UserManagerConfig in project BiglyBT by BiglySoftware.

the class UserManagerXMLPersist method doSave.

/**
 * This code abstracted because it relies on java.beans.* which is not always available
 * e.g. on Android
 */
@Override
public void doSave(OutputStream out, Map usersMap) {
    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();
}
Also used : XMLEncoder(java.beans.XMLEncoder) ArrayList(java.util.ArrayList) UserManagerConfig(com.biglybt.ui.console.multiuser.UserManager.UserManagerConfig) List(java.util.List) ArrayList(java.util.ArrayList) BufferedOutputStream(java.io.BufferedOutputStream)

Example 2 with UserManagerConfig

use of com.biglybt.ui.console.multiuser.UserManager.UserManagerConfig in project BiglyBT by BiglySoftware.

the class UserManagerXMLPersist method doLoad.

@Override
public void doLoad(InputStream in, Map usersMap) {
    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();
}
Also used : UserProfile(com.biglybt.ui.console.UserProfile) XMLDecoder(java.beans.XMLDecoder) Iterator(java.util.Iterator) UserManagerConfig(com.biglybt.ui.console.multiuser.UserManager.UserManagerConfig)

Aggregations

UserManagerConfig (com.biglybt.ui.console.multiuser.UserManager.UserManagerConfig)2 UserProfile (com.biglybt.ui.console.UserProfile)1 XMLDecoder (java.beans.XMLDecoder)1 XMLEncoder (java.beans.XMLEncoder)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1