예제 #1
0
  @Transactional
  @Override
  public net.sourceforge.guacamole.net.auth.User get(String identifier) throws GuacamoleException {

    // Get user
    MySQLUser user = userService.retrieveUser(identifier);

    // Verify access is granted
    permissionCheckService.verifyUserAccess(
        this.user_id, user.getUserID(), MySQLConstants.USER_READ);

    // Return user
    return userService.retrieveUser(identifier);
  }
예제 #2
0
  @Override
  @Transactional
  public void remove(String identifier) throws GuacamoleException {

    // Get user pending deletion
    MySQLUser user = userService.retrieveUser(identifier);

    // Prevent self-deletion
    if (user.getUserID() == this.user_id)
      throw new GuacamoleClientException("Deleting your own user is not allowed.");

    // Validate current user has permission to remove the specified user
    permissionCheckService.verifyUserAccess(
        this.user_id, user.getUserID(), MySQLConstants.USER_DELETE);

    // Delete specified user
    userService.deleteUser(user.getUserID());
  }
예제 #3
0
  @Override
  @Transactional
  public void add(net.sourceforge.guacamole.net.auth.User object) throws GuacamoleException {

    String username = object.getUsername().trim();
    if (username.isEmpty()) throw new GuacamoleClientException("The username cannot be blank.");

    // Verify current user has permission to create users
    permissionCheckService.verifySystemAccess(this.user_id, MySQLConstants.SYSTEM_USER_CREATE);
    Preconditions.checkNotNull(object);

    // Verify that no user already exists with this username.
    MySQLUser previousUser = userService.retrieveUser(username);
    if (previousUser != null)
      throw new GuacamoleClientException("That username is already in use.");

    // Create new user
    MySQLUser user = userService.createUser(username, object.getPassword());

    // Create permissions of new user in database
    createPermissions(user.getUserID(), object.getPermissions());

    // Give the current user full access to the newly created user.
    UserPermissionKey newUserPermission = new UserPermissionKey();
    newUserPermission.setUser_id(this.user_id);
    newUserPermission.setAffected_user_id(user.getUserID());

    // READ permission on new user
    newUserPermission.setPermission(MySQLConstants.USER_READ);
    userPermissionDAO.insert(newUserPermission);

    // UPDATE permission on new user
    newUserPermission.setPermission(MySQLConstants.USER_UPDATE);
    userPermissionDAO.insert(newUserPermission);

    // DELETE permission on new user
    newUserPermission.setPermission(MySQLConstants.USER_DELETE);
    userPermissionDAO.insert(newUserPermission);

    // ADMINISTER permission on new user
    newUserPermission.setPermission(MySQLConstants.USER_ADMINISTER);
    userPermissionDAO.insert(newUserPermission);
  }