/** @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;
 }
 /**
  * Returns whether or not the given role is a predefined role.
  *
  * <p>Currently, there's only a single predefined role: {@link Role#USER_ANYONE}.
  *
  * @param roleName the role name to check, may be <code>null</code>.
  * @return <code>true</code> if the given role is predefined, <code>false</code> otherwise.
  */
 private boolean isPredefinedRole(String roleName) {
   return Role.USER_ANYONE.equals(roleName);
 }
Exemple #3
0
 @Override
 public boolean implies(Optional<User> user, Map<String, Boolean> checked) {
   return Role.USER_ANYONE.equals(getName());
 }