Class UserAndRoleDirectoryServiceImpl
java.lang.Object
org.opencastproject.userdirectory.UserAndRoleDirectoryServiceImpl
- All Implemented Interfaces:
RoleDirectoryService,UserDirectoryService,org.springframework.security.core.userdetails.UserDetailsService
public class UserAndRoleDirectoryServiceImpl
extends Object
implements UserDirectoryService, org.springframework.security.core.userdetails.UserDetailsService, RoleDirectoryService
Federates user and role providers, and exposes a spring UserDetailsService so user lookups can be used by spring
security.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<RoleProvider> The list of role providersprotected SecurityServiceThe security servicestatic final StringThe configuration property for the user cache expiry timestatic final StringThe configuration property for the user cache sizeprotected List<UserProvider> The list of user providers -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidactivate(org.osgi.service.component.ComponentContext cc) Callback to activate the component.protected voidaddRoleProvider(RoleProvider roleProvider) Adds a role provider.protected voidaddUserProvider(UserProvider userProvider) Adds a user provider.longReturns the total number of usersfindRoles(String query, Role.Target target, int offset, int limit) Return the found roles as a list.Return the found user's as an iterator.getUsers()Gets all known users.voidinvalidate(String userName) Discards any cached value for given user name.Loads a user by username, or returns null if this user is not known to the thread's current organization.org.springframework.security.core.userdetails.UserDetailsloadUserByUsername(String userName) loadUsers(Collection<String> userNames) Loads multiple users by a list of user names.protected voidremoveRoleProvider(RoleProvider roleProvider) Remove a role provider.protected voidremoveUserProvider(UserProvider userProvider) Remove a user provider.voidsetSecurityService(SecurityService securityService) Sets the security service
-
Field Details
-
USER_CACHE_SIZE_KEY
The configuration property for the user cache size- See Also:
-
USER_CACHE_EXPIRY_KEY
The configuration property for the user cache expiry time- See Also:
-
userProviders
The list of user providers -
roleProviders
The list of role providers -
securityService
The security service
-
-
Constructor Details
-
UserAndRoleDirectoryServiceImpl
public UserAndRoleDirectoryServiceImpl()
-
-
Method Details
-
activate
protected void activate(org.osgi.service.component.ComponentContext cc) Callback to activate the component.- Parameters:
cc- the declarative services component context
-
addUserProvider
Adds a user provider.- Parameters:
userProvider- the user provider to add
-
removeUserProvider
Remove a user provider.- Parameters:
userProvider- the user provider to remove
-
addRoleProvider
Adds a role provider.- Parameters:
roleProvider- the role provider to add
-
removeRoleProvider
Remove a role provider.- Parameters:
roleProvider- the role provider to remove
-
getUsers
Gets all known users.- Specified by:
getUsersin interfaceUserDirectoryService- Returns:
- the users
- See Also:
-
loadUser
Loads a user by username, or returns null if this user is not known to the thread's current organization.- Specified by:
loadUserin interfaceUserDirectoryService- Parameters:
userName- the username- Returns:
- the user
- Throws:
IllegalStateException- if no organization is set for the current thread- See Also:
-
loadUsers
Description copied from interface:UserDirectoryServiceLoads multiple users by a list of user names.- Specified by:
loadUsersin interfaceUserDirectoryService- Parameters:
userNames- the user names to look for- Returns:
- the users
-
loadUserByUsername
public org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String userName) throws org.springframework.security.core.userdetails.UsernameNotFoundException - Specified by:
loadUserByUsernamein interfaceorg.springframework.security.core.userdetails.UserDetailsService- Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException- See Also:
-
setSecurityService
Sets the security service- Parameters:
securityService- the securityService to set
-
findUsers
Description copied from interface:UserDirectoryServiceReturn the found user's as an iterator.- Specified by:
findUsersin interfaceUserDirectoryService- Parameters:
query- the query. Use the wildcards "_" to match any single character and "%" to match an arbitrary number of characters (including zero characters).offset- the offsetlimit- the limit. 0 means no limit- Returns:
- an iterator of user's
-
findRoles
Description copied from interface:RoleDirectoryServiceReturn the found roles as a list.- Specified by:
findRolesin interfaceRoleDirectoryService- Parameters:
query- the query. Use the wildcards "_" to match any single character and "%" to match an arbitrary number of characters (including zero characters).offset- the offset.limit- the limit. 0 means no limit- Returns:
- a list of roles
-
countUsers
public long countUsers()Description copied from interface:UserDirectoryServiceReturns the total number of users- Specified by:
countUsersin interfaceUserDirectoryService- Returns:
- the count of users
-
invalidate
Description copied from interface:UserDirectoryServiceDiscards any cached value for given user name.- Specified by:
invalidatein interfaceUserDirectoryService- Parameters:
userName- the user name
-