Class SakaiUserProviderInstance

java.lang.Object
org.opencastproject.userdirectory.sakai.SakaiUserProviderInstance
All Implemented Interfaces:
CachingUserProviderMXBean, RoleProvider, UserProvider

public class SakaiUserProviderInstance extends Object implements UserProvider, RoleProvider, CachingUserProviderMXBean
A UserProvider that reads user roles from Sakai.
  • Field Details

  • Constructor Details

    • SakaiUserProviderInstance

      public SakaiUserProviderInstance(String pid, Organization organization, String url, String userName, String password, String sitePattern, String userPattern, Set<String> instructorRoles, int cacheSize, int cacheExpiration)
      Constructs an Sakai user provider with the needed settings.
      Parameters:
      pid - the pid of this service
      organization - the organization
      url - the url of the Sakai server
      userName - the user to authenticate as
      password - the user credentials
      cacheSize - the number of users to cache
      cacheExpiration - the number of minutes to cache users
  • Method Details

    • getName

      public String getName()
      Description copied from interface: UserProvider
      Gets the provider name
      Specified by:
      getName in interface UserProvider
      Returns:
      the provider name
    • registerMBean

      protected void registerMBean(String pid)
      Registers an MXBean.
    • getOrganization

      public String getOrganization()
      Returns the identifier for the organization that is associated with this user provider. If equal to UserProvider.ALL_ORGANIZATIONS, this provider will always be consulted, regardless of the organization.
      Specified by:
      getOrganization in interface RoleProvider
      Specified by:
      getOrganization in interface UserProvider
      Returns:
      the defining organization
      See Also:
    • loadUser

      public User loadUser(String userName)
      Loads a user by username, or returns null if this user is not known to this provider.
      Specified by:
      loadUser in interface UserProvider
      Parameters:
      userName - the username
      Returns:
      the user
      See Also:
    • loadUserFromSakai

      protected User loadUserFromSakai(String userName)
      Loads a user from Sakai.
      Parameters:
      userName - the username
      Returns:
      the user
    • getCacheHitRatio

      public float getCacheHitRatio()
      Gets the ratio of cache hits to total requests.
      Specified by:
      getCacheHitRatio in interface CachingUserProviderMXBean
      Returns:
      the hit ratio
      See Also:
    • findUsers

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

      public Iterator<User> getUsers()
      Description copied from interface: UserProvider
      Gets all known users.
      Specified by:
      getUsers in interface UserProvider
      Returns:
      the users
    • invalidate

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

      public long countUsers()
      Description copied from interface: UserProvider
      Returns the number of users in the provider
      Specified by:
      countUsers in interface UserProvider
      Returns:
      the count of users in the provider
    • getRolesForUser

      public List<Role> getRolesForUser(String userName)
      Description copied from interface: RoleProvider
      Returns the roles for this user or an empty array if no roles are applicable.
      Specified by:
      getRolesForUser in interface RoleProvider
      Parameters:
      userName - the user id
      Returns:
      the set of roles
    • findRoles

      public Iterator<Role> findRoles(String query, Role.Target target, int offset, int limit)
      Description copied from interface: RoleProvider
      Return the found roles as an iterator.
      Specified by:
      findRoles in interface RoleProvider
      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 role's