/**
  * Removes a given role as (required)member from any groups it is member of.
  *
  * @param removedRole the role that is removed from the store already, cannot be <code>null</code>
  *     .
  * @throws BackendException in case of problems accessing the store.
  */
 private void removeRoleFromAllGroups(Role removedRole) {
   try {
     Role[] roles = m_store.getRoles(null);
     for (int i = 0; i < roles.length; i++) {
       if (roles[i].getType() == Role.GROUP) {
         Group group = (Group) roles[i];
         // Don't check whether the given role is actually a member
         // of the group, but let the group itself figure this out...
         group.removeMember(removedRole);
       }
     }
   } catch (Exception e) {
     throw new BackendException("Failed to get all roles!", e);
   }
 }
Beispiel #2
0
  @Override
  public void setUserAdmin(final UserAdmin inUserAdmin) {
    super.setUserAdmin(inUserAdmin);

    final User lAdmin = (User) inUserAdmin.createRole(Constants.USER_NAME_ADMIN, Role.USER);
    setNamePassword(lAdmin, Constants.USER_NAME_ADMIN, Constants.USER_PW_ADMIN);

    final User lUser = (User) inUserAdmin.createRole(Constants.USER_NAME_USER, Role.USER);
    setNamePassword(lUser, Constants.USER_NAME_USER, Constants.USER_PW_USER);

    final Group lAdministrators =
        (Group) inUserAdmin.createRole(Constants.ADMIN_GROUP_NAME, Role.GROUP);
    if (lAdministrators != null) {
      lAdministrators.addRequiredMember(lAdmin);
      lAdministrators.addMember(inUserAdmin.getRole(Role.USER_ANYONE));
    }
    initializePermissions();
  }