com.atlassian.crowd.service.cache
Class CachingGroupMembershipManager

java.lang.Object
  extended by com.atlassian.crowd.service.cache.CachingGroupMembershipManager
All Implemented Interfaces:
GroupMembershipManager

public class CachingGroupMembershipManager
extends Object
implements GroupMembershipManager

This class handles group memberships, but also handles some funky translation


Constructor Summary
CachingGroupMembershipManager(SecurityServerClient securityServerClient, UserManager userManager, GroupManager groupManager, BasicCache basicCache)
           
 
Method Summary
 void addMembership(String userName, String groupName)
          Adds a user identified by userName to the group identified by groupName.
 List getMembers(String groupName)
          Also see CachingGroupManager.getGroup(String) for very similar logic.
 List getMemberships(String userName)
          Obtains a list of all groups that the user identified by userName belongs to, sorted naturally.
 boolean isMember(String userName, String groupName)
          Returns true if the user represented by userName is a member of groupName
 Boolean isUserOrGroup(String name)
           
 void removeMembership(String userName, String groupName)
          Removes a user identified by userName from the group identified by groupName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingGroupMembershipManager

public CachingGroupMembershipManager(SecurityServerClient securityServerClient,
                                     UserManager userManager,
                                     GroupManager groupManager,
                                     BasicCache basicCache)
Method Detail

isMember

public boolean isMember(String userName,
                        String groupName)
                 throws RemoteException,
                        InvalidAuthorizationTokenException,
                        InvalidAuthenticationException
Description copied from interface: GroupMembershipManager
Returns true if the user represented by userName is a member of groupName

Specified by:
isMember in interface GroupMembershipManager
Parameters:
userName - The user to check
groupName - The group to check.
Returns:
true if a member, false otherwise.
Throws:
RemoteException - A communication error occurred - the Crowd server may not be available.
InvalidAuthorizationTokenException - The application (not the user) was not authenticated correctly.
InvalidAuthenticationException - application authentication is not valid

addMembership

public void addMembership(String userName,
                          String groupName)
                   throws RemoteException,
                          InvalidAuthorizationTokenException,
                          ApplicationPermissionException,
                          InvalidAuthenticationException,
                          UserNotFoundException,
                          GroupNotFoundException
Description copied from interface: GroupMembershipManager
Adds a user identified by userName to the group identified by groupName. If the user is already a member of the group, this method will return successfully.

Specified by:
addMembership in interface GroupMembershipManager
Parameters:
userName - The user to add
groupName - The group the user will be added to
Throws:
RemoteException - A communication error occurred - the Crowd server may not be available.
InvalidAuthorizationTokenException - The application (not the user) was not authenticated correctly.
ApplicationPermissionException - This application does not have permission to update group memberships.
InvalidAuthenticationException - application authentication is not valid
UserNotFoundException - the user could not be found
GroupNotFoundException - the group could not be found

removeMembership

public void removeMembership(String userName,
                             String groupName)
                      throws RemoteException,
                             InvalidAuthorizationTokenException,
                             ApplicationPermissionException,
                             MembershipNotFoundException,
                             UserNotFoundException,
                             InvalidAuthenticationException,
                             GroupNotFoundException
Description copied from interface: GroupMembershipManager
Removes a user identified by userName from the group identified by groupName. If the user was not a member of the group, this method will return successfully.

Specified by:
removeMembership in interface GroupMembershipManager
Parameters:
userName - The user to remove
groupName - The group the user will be added from
Throws:
RemoteException - A communication error occurred - the Crowd server may not be available.
InvalidAuthorizationTokenException - The application (not the user) was not authenticated correctly.
ApplicationPermissionException - This application does not have permission to update group memberships.
MembershipNotFoundException - Unable to find membership
UserNotFoundException - the user could not be found
InvalidAuthenticationException - application authentication is not valid
GroupNotFoundException - the group could not be found

getMemberships

public List getMemberships(String userName)
                    throws RemoteException,
                           InvalidAuthorizationTokenException,
                           InvalidAuthenticationException,
                           UserNotFoundException
Description copied from interface: GroupMembershipManager
Obtains a list of all groups that the user identified by userName belongs to, sorted naturally.

This can be a slow call, particularly on some LDAP directories, and so should be avoided. Use isMember() instead.

Specified by:
getMemberships in interface GroupMembershipManager
Parameters:
userName - The user whose group memberships are desired.
Returns:
A List of Strings containing all the groups the user belongs to, or an empty List
Throws:
RemoteException - A communication error occurred - the Crowd server may not be available.
InvalidAuthorizationTokenException - The application (not the user) was not authenticated correctly.
InvalidAuthenticationException - application authentication is not valid
UserNotFoundException - If the user could not be found.

getMembers

public List getMembers(String groupName)
                throws RemoteException,
                       InvalidAuthorizationTokenException,
                       InvalidAuthenticationException,
                       GroupNotFoundException
Also see CachingGroupManager.getGroup(String) for very similar logic.

Specified by:
getMembers in interface GroupMembershipManager
Parameters:
groupName - The group whose member users are desired.
Returns:
A List of Strings containing all the users in the group, or an empty list.
Throws:
RemoteException - A communication error occurred - the Crowd server may not be available.
InvalidAuthorizationTokenException - The application (not the user) was not authenticated correctly.
InvalidAuthenticationException - application authentication is not valid
GroupNotFoundException - If the group could not be found.

isUserOrGroup

public Boolean isUserOrGroup(String name)
                      throws InvalidAuthorizationTokenException,
                             RemoteException,
                             InvalidAuthenticationException
Throws:
InvalidAuthorizationTokenException
RemoteException
InvalidAuthenticationException


Copyright © 2013 Atlassian. All Rights Reserved.