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, Boolean hasUser) Return the found roles as a list, optionally filtered by whether or not each role corresponds to an actual user account.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 serviceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opencastproject.security.api.RoleDirectoryService
findRoles
-
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
public List<Role> findRoles(String query, Role.Target target, int offset, int limit, Boolean hasUser) Description copied from interface:RoleDirectoryServiceReturn the found roles as a list, optionally filtered by whether or not each role corresponds to an actual user account.- 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 limithasUser- ifnull, roles are not filtered by this criterion. Iftrue, only roles that resolve to an actual user account are returned. Iffalse, only roles that do not resolve to a user account are returned. The filter, if any, is applied before the offset/limit are applied.- 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
-