Hi,

I'm trying to understand how to add and remove users, roles, groups.

Specifically, in my app I have "groups" which users belong too.  When my
administrator removes a group, I'd like to remove all user privileges in
that group.  But for some reason their is a TurbineSecurity.revokeAll for
users and roles, but not groups.

I came up with the following rather ugly bit of code...

   // delete the simulation group
   Group SimGroup=null;
   try {
    SimGroup = TurbineSecurity.getGroup(MySim.getSimGroup());
    Role DevRole = TurbineSecurity.getRole("developer");

    // remove all user permissions in this group
    // terribly inefficient-- fix this
    Criteria ucrit = new Criteria();
    User [] UserList = TurbineSecurity.getUsers(ucrit);
    if (UserList != null)
     for (int u=0; u < UserList.length; u++) {
      AccessControlList ACL = TurbineSecurity.getACL(UserList[u]);
      if (ACL.hasRole(DevRole,SimGroup))
       TurbineSecurity.revoke(UserList[u],SimGroup,DevRole);
     }

    // remove the group
    TurbineSecurity.removeGroup(SimGroup);

   } catch (UnknownEntityException E)
   { Log.warn("SimAdmin", "Couldn't remove Turbine group " + SimGroup);
   }

Unfortunately, it doesn't work!  When I finish, the group defined by
"SimGroup" is indeed gone.  But the table "Turbine_User_Group_Role" still
has entries corresponding to the group ID for this group.   The only thing I
can think of is that I created that database by hand (rather than using
TurbineSecurity.grant), so maybe it wasn't populated correctly.  Ideas would
be appreciated -- thanks!


WILL



_______________________________________
Forio Business Simulations
Will Glass-Husain
(415) 440-7500 phone
(415) 235-4293 mobile
[EMAIL PROTECTED]
www.forio.com


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to