Search in sources :

Example 1 with IUserManagerListener

use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUserManagerListener in project binnavi by google.

the class CUserManager method deleteUser.

/**
 * Removes a user from user management and deletes him from the database.
 *
 * @param user
 * @throws CouldntDeleteException
 */
public synchronized void deleteUser(final IUser user) throws CouldntDeleteException {
    Preconditions.checkNotNull(user, "IE02721: user argument can not be null");
    if (!users.contains(user)) {
        throw new IllegalStateException("IE02722: User is not known to the user management.");
    }
    provider.deleteUser(user);
    for (final IUserManagerListener listener : listeners) {
        try {
            listener.deletedUser(user);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : IUserManagerListener(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUserManagerListener) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

Example 2 with IUserManagerListener

use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUserManagerListener in project binnavi by google.

the class CUserManager method editUserName.

/**
 * Edits a users user name to something else.
 *
 * @param user The user where the name should be changed.
 * @param userName The user name to change the name of the user to.
 *
 * @return The new user.
 * @throws CouldntSaveDataException
 */
public synchronized IUser editUserName(final IUser user, final String userName) throws CouldntSaveDataException {
    Preconditions.checkNotNull(user, "IE02723: user argument can not be null");
    Preconditions.checkNotNull(userName, "IE02724: userName argument can not be null");
    if (!users.contains(user)) {
        throw new IllegalStateException("IE02725: User is not known to the user management.");
    }
    if (containsUserName(userName)) {
        throw new IllegalStateException("IE02726: User name is already in use by another user.");
    }
    final IUser newUser = provider.editUserName(user, userName);
    for (final IUserManagerListener listener : listeners) {
        try {
            listener.editedUser(newUser);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    return newUser;
}
Also used : IUserManagerListener(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUserManagerListener) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

Example 3 with IUserManagerListener

use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUserManagerListener in project binnavi by google.

the class CUserManager method addUser.

/**
 * Adds a user to the user management and saves the information to the database
 *
 * @param userName The name of the user to be added to user management.
 *
 * @return The user.
 * @throws CouldntSaveDataException
 */
public synchronized IUser addUser(final String userName) throws CouldntSaveDataException {
    Preconditions.checkNotNull(userName, "IE02718: user name argument can not be null.");
    if (containsUserName(userName)) {
        throw new IllegalStateException("IE02719: User is already known to user management.");
    }
    final IUser user = provider.addUser(userName);
    users.add(user);
    for (final IUserManagerListener listener : listeners) {
        try {
            listener.addedUser(user);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    return user;
}
Also used : IUserManagerListener(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUserManagerListener) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

Aggregations

CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)3 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)3 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)3 IUserManagerListener (com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUserManagerListener)3 IUser (com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser)2