/** @see UserAdmin#removeRole(String) */
 @Override
 public boolean removeRole(String name) {
   if (null == name) {
     throw (new IllegalArgumentException(UserAdminMessages.MSG_INVALID_NAME));
   }
   if (!"".equals(name) && !Role.USER_ANYONE.equals(name)) {
     Role role = getRole(name);
     if (null != role) {
       checkAdminPermission();
       try {
         StorageProvider storageProvider = getStorageProvider();
         if (storageProvider.deleteRole(role)) {
           fireEvent(UserAdminEvent.ROLE_REMOVED, role);
           return true;
         } else {
           logMessage(this, LogService.LOG_ERROR, "Role '" + name + "' could not be deleted");
         }
       } catch (StorageException e) {
         logMessage(this, LogService.LOG_ERROR, e.getMessage());
       }
     } else {
       logMessage(this, LogService.LOG_ERROR, "Role '" + name + "' does not exist.");
     }
   } else {
     logMessage(
         this,
         LogService.LOG_ERROR,
         "Standard user '" + Role.USER_ANYONE + "' cannot be removed.");
   }
   return false;
 }
 /** @see UserAdmin#getRoles(String) */
 @Override
 public Role[] getRoles(String filter) throws InvalidSyntaxException {
   try {
     StorageProvider storage = getStorageProvider();
     Collection<Role> roles = storage.findRoles(this, filter);
     if (!roles.isEmpty()) {
       return roles.toArray(new Role[roles.size()]);
     }
   } catch (StorageException e) {
     logMessage(this, LogService.LOG_ERROR, e.getMessage());
   }
   return null;
 }
 /** @see UserAdmin#getUser(String, String) */
 @Override
 public User getUser(String key, String value) {
   if (null == key) {
     throw new IllegalArgumentException(UserAdminMessages.MSG_INVALID_KEY);
   }
   if (null == value) {
     throw new IllegalArgumentException(UserAdminMessages.MSG_INVALID_VALUE);
   }
   try {
     StorageProvider storage = getStorageProvider();
     return storage.getUser(this, key, value);
   } catch (StorageException e) {
     logMessage(this, LogService.LOG_ERROR, e.getMessage());
   }
   return null;
 }
 /** @see UserAdmin#getRole(String) */
 @Override
 public Role getRole(String name) {
   if (null == name) {
     throw (new IllegalArgumentException(UserAdminMessages.MSG_INVALID_NAME));
   }
   if ("".equals(name)) {
     name = Role.USER_ANYONE;
   }
   //
   try {
     StorageProvider storage = getStorageProvider();
     return storage.getRole(this, name);
   } catch (StorageException e) {
     logMessage(this, LogService.LOG_ERROR, e.getMessage());
   }
   return null;
 }
  /** @see UserAdmin#createRole(String, int) */
  @Override
  public Role createRole(String name, int type) {
    checkAdminPermission();
    //
    if (null == name || name.trim().length() == 0) {
      throw new IllegalArgumentException(UserAdminMessages.MSG_INVALID_NAME);
    }
    if (!((type == Role.GROUP) || (type == Role.USER))) {
      throw new IllegalArgumentException(UserAdminMessages.MSG_INVALID_ROLE_TYPE);
    }
    //
    // return null if the role already exists (see chapter 107.8.6.1)
    //
    if (null != getRole(name)) {
      logMessage(this, LogService.LOG_INFO, "createRole() - role already exists: " + name);
      return null;
    }
    //
    Role role = null;
    try {
      StorageProvider storageProvider = getStorageProvider();
      switch (type) {
        case Role.USER:
          role = storageProvider.createUser(this, name);
          break;

        case Role.GROUP:
          role = storageProvider.createGroup(this, name);
          break;

        default:
          // never reached b/o previous checks
      }
      fireEvent(UserAdminEvent.ROLE_CREATED, role);
      logMessage(this, LogService.LOG_INFO, "role created: " + name + " - " + role);
    } catch (StorageException e) {
      logMessage(this, LogService.LOG_ERROR, e.getMessage());
    }
    return role;
  }