Class JpaUserReferenceProvider

java.lang.Object
org.opencastproject.userdirectory.JpaUserReferenceProvider
All Implemented Interfaces:
org.opencastproject.security.api.RoleProvider, org.opencastproject.security.api.UserProvider, UserReferenceProvider

public class JpaUserReferenceProvider extends Object implements UserReferenceProvider, org.opencastproject.security.api.UserProvider, org.opencastproject.security.api.RoleProvider
Manages and locates users references using JPA.
  • Field Details

    • PROVIDER_NAME

      public static final String PROVIDER_NAME
      See Also:
    • USERNAME

      public static final String USERNAME
      Username constant used in JSON formatted users
      See Also:
    • ROLES

      public static final String ROLES
      Role constant used in JSON formatted users
      See Also:
    • ENCODING

      public static final String ENCODING
      Encoding expected from all inputs
      See Also:
    • securityService

      protected org.opencastproject.security.api.SecurityService securityService
      The security service
    • groupRoleProvider

      protected JpaGroupRoleProvider groupRoleProvider
      Group Role provider
    • roleProvider

      protected AAIRoleProvider roleProvider
      Role provider
    • nullToken

      protected final Object nullToken
      A token to store in the miss cache
    • emf

      protected javax.persistence.EntityManagerFactory emf
      The factory used to generate the entity manager
    • dbSessionFactory

      protected org.opencastproject.db.DBSessionFactory dbSessionFactory
    • db

      protected org.opencastproject.db.DBSession db
  • Constructor Details

    • JpaUserReferenceProvider

      public JpaUserReferenceProvider()
  • Method Details

    • setDBSessionFactory

      public void setDBSessionFactory(org.opencastproject.db.DBSessionFactory dbSessionFactory)
    • setSecurityService

      public void setSecurityService(org.opencastproject.security.api.SecurityService securityService)
      Parameters:
      securityService - the securityService to set
    • setGroupRoleProvider

      public void setGroupRoleProvider(JpaGroupRoleProvider groupRoleProvider)
      Parameters:
      groupRoleProvider - the GroupRoleProvider to set
    • activate

      public void activate(org.osgi.service.component.ComponentContext cc)
      Callback for activation of this component.
      Parameters:
      cc - the component context
    • getName

      public String getName()
      Specified by:
      getName in interface org.opencastproject.security.api.UserProvider
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • getRolesForUser

      public List<org.opencastproject.security.api.Role> getRolesForUser(String userName)
      Specified by:
      getRolesForUser in interface org.opencastproject.security.api.RoleProvider
      See Also:
      • RoleProvider.getRolesForUser(String)
    • findUsers

      public Iterator<org.opencastproject.security.api.User> findUsers(String query, int offset, int limit)
      Specified by:
      findUsers in interface org.opencastproject.security.api.UserProvider
      See Also:
      • UserProvider.findUsers(String, int, int)
    • findUsers

      public Iterator<org.opencastproject.security.api.User> findUsers(Collection<String> userNames)
      Specified by:
      findUsers in interface org.opencastproject.security.api.UserProvider
    • findRoles

      public Iterator<org.opencastproject.security.api.Role> findRoles(String query, org.opencastproject.security.api.Role.Target target, int offset, int limit)
      Specified by:
      findRoles in interface org.opencastproject.security.api.RoleProvider
      See Also:
      • RoleProvider.findRoles(String, Role.Target, int, int)
    • loadUser

      public org.opencastproject.security.api.User loadUser(String userName)
      Load a user by userName
      Specified by:
      loadUser in interface org.opencastproject.security.api.UserProvider
      Specified by:
      loadUser in interface UserReferenceProvider
      Parameters:
      userName -
      Returns:
      the user or null if not found
      See Also:
      • UserProvider.loadUser(java.lang.String)
    • getUsers

      public Iterator<org.opencastproject.security.api.User> getUsers()
      Specified by:
      getUsers in interface org.opencastproject.security.api.UserProvider
    • getRoles

      public Iterator<org.opencastproject.security.api.Role> getRoles()
      Return the roles
      Returns:
      the roles
    • getOrganization

      public String getOrganization()
      Specified by:
      getOrganization in interface org.opencastproject.security.api.RoleProvider
      Specified by:
      getOrganization in interface org.opencastproject.security.api.UserProvider
      See Also:
      • UserProvider.getOrganization()
    • addUserReference

      public void addUserReference(org.opencastproject.security.impl.jpa.JpaUserReference user, String mechanism)
      Add a user reference
      Specified by:
      addUserReference in interface UserReferenceProvider
      Parameters:
      user - the user reference to be added
      mechanism - the mechanism that adds the user reference
    • updateUserReference

      public void updateUserReference(org.opencastproject.security.impl.jpa.JpaUserReference user)
      Update an existing user reference
      Specified by:
      updateUserReference in interface UserReferenceProvider
      Parameters:
      user - the user reference to be updated
    • findUserReference

      public org.opencastproject.security.impl.jpa.JpaUserReference findUserReference(String userName, String organizationId)
      Returns the persisted user reference by the user name and organization id
      Specified by:
      findUserReference in interface UserReferenceProvider
      Parameters:
      userName - the user name
      organizationId - the organization id
      Returns:
      the user or null if not found
    • countUsers

      public long countUsers()
      Specified by:
      countUsers in interface org.opencastproject.security.api.UserProvider
    • invalidate

      public void invalidate(String userName)
      Specified by:
      invalidate in interface org.opencastproject.security.api.UserProvider
    • deleteUser

      public void deleteUser(String username, String orgId) throws org.opencastproject.util.NotFoundException, org.opencastproject.security.api.UnauthorizedException, Exception
      Delete the given user
      Parameters:
      username - the name of the user to delete
      orgId - the organization id
      Throws:
      org.opencastproject.util.NotFoundException - if the requested user is not exist
      org.opencastproject.security.api.UnauthorizedException - if you havn't permissions to delete an admin user (only admins may do that)
      Exception
    • setRoleProvider

      public void setRoleProvider(org.opencastproject.security.api.RoleProvider roleProvider)
      Description copied from interface: UserReferenceProvider
      Set an optional roleProvider that takes care about resolving roles
      Specified by:
      setRoleProvider in interface UserReferenceProvider
      Parameters:
      roleProvider -