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 Details

    • USER_CACHE_SIZE_KEY

      public static final String USER_CACHE_SIZE_KEY
      The configuration property for the user cache size
      See Also:
    • USER_CACHE_EXPIRY_KEY

      public static final String USER_CACHE_EXPIRY_KEY
      The configuration property for the user cache expiry time
      See Also:
    • userProviders

      protected List<UserProvider> userProviders
      The list of user providers
    • roleProviders

      protected List<RoleProvider> roleProviders
      The list of role providers
    • securityService

      protected SecurityService 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

      protected void addUserProvider(UserProvider userProvider)
      Adds a user provider.
      Parameters:
      userProvider - the user provider to add
    • removeUserProvider

      protected void removeUserProvider(UserProvider userProvider)
      Remove a user provider.
      Parameters:
      userProvider - the user provider to remove
    • addRoleProvider

      protected void addRoleProvider(RoleProvider roleProvider)
      Adds a role provider.
      Parameters:
      roleProvider - the role provider to add
    • removeRoleProvider

      protected void removeRoleProvider(RoleProvider roleProvider)
      Remove a role provider.
      Parameters:
      roleProvider - the role provider to remove
    • getUsers

      public Iterator<User> getUsers()
      Gets all known users.
      Specified by:
      getUsers in interface UserDirectoryService
      Returns:
      the users
      See Also:
    • loadUser

      public User loadUser(String userName) throws IllegalStateException
      Loads a user by username, or returns null if this user is not known to the thread's current organization.
      Specified by:
      loadUser in interface UserDirectoryService
      Parameters:
      userName - the username
      Returns:
      the user
      Throws:
      IllegalStateException - if no organization is set for the current thread
      See Also:
    • loadUsers

      public Iterator<User> loadUsers(Collection<String> userNames)
      Description copied from interface: UserDirectoryService
      Loads multiple users by a list of user names.
      Specified by:
      loadUsers in interface UserDirectoryService
      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:
      loadUserByUsername in interface org.springframework.security.core.userdetails.UserDetailsService
      Throws:
      org.springframework.security.core.userdetails.UsernameNotFoundException
      See Also:
      • UserDetailsService.loadUserByUsername(java.lang.String)
    • setSecurityService

      public void setSecurityService(SecurityService securityService)
      Sets the security service
      Parameters:
      securityService - the securityService to set
    • findUsers

      public Iterator<User> findUsers(String query, int offset, int limit)
      Description copied from interface: UserDirectoryService
      Return the found user's as an iterator.
      Specified by:
      findUsers in interface UserDirectoryService
      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:
      an iterator of user's
    • findRoles

      public List<Role> findRoles(String query, Role.Target target, int offset, int limit)
      Description copied from interface: RoleDirectoryService
      Return the found roles as a list.
      Specified by:
      findRoles in interface RoleDirectoryService
      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: UserDirectoryService
      Returns the total number of users
      Specified by:
      countUsers in interface UserDirectoryService
      Returns:
      the count of users
    • invalidate

      public void invalidate(String userName)
      Description copied from interface: UserDirectoryService
      Discards any cached value for given user name.
      Specified by:
      invalidate in interface UserDirectoryService
      Parameters:
      userName - the user name