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 Summary
FieldsModifier and TypeFieldDescriptionprotected org.opencastproject.db.DBSessionprotected org.opencastproject.db.DBSessionFactoryprotected javax.persistence.EntityManagerFactoryThe factory used to generate the entity managerstatic final StringEncoding expected from all inputsprotected JpaGroupRoleProviderGroup Role providerprotected final ObjectA token to store in the miss cachestatic final Stringprotected AAIRoleProviderRole providerstatic final StringRole constant used in JSON formatted usersprotected org.opencastproject.security.api.SecurityServiceThe security servicestatic final StringUsername constant used in JSON formatted usersFields inherited from interface org.opencastproject.security.api.UserProvider
ALL_ORGANIZATIONS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) Callback for activation of this component.voidaddUserReference(org.opencastproject.security.impl.jpa.JpaUserReference user, String mechanism) Add a user referencelongvoiddeleteUser(String username, String orgId) Delete the given userIterator<org.opencastproject.security.api.Role> org.opencastproject.security.impl.jpa.JpaUserReferencefindUserReference(String userName, String organizationId) Returns the persisted user reference by the user name and organization idIterator<org.opencastproject.security.api.User> Iterator<org.opencastproject.security.api.User> findUsers(Collection<String> userNames) getName()Iterator<org.opencastproject.security.api.Role> getRoles()Return the rolesList<org.opencastproject.security.api.Role> getRolesForUser(String userName) Iterator<org.opencastproject.security.api.User> getUsers()voidinvalidate(String userName) org.opencastproject.security.api.UserLoad a user by userNamevoidsetDBSessionFactory(org.opencastproject.db.DBSessionFactory dbSessionFactory) voidsetGroupRoleProvider(JpaGroupRoleProvider groupRoleProvider) voidsetRoleProvider(org.opencastproject.security.api.RoleProvider roleProvider) Set an optional roleProvider that takes care about resolving rolesvoidsetSecurityService(org.opencastproject.security.api.SecurityService securityService) toString()voidupdateUserReference(org.opencastproject.security.impl.jpa.JpaUserReference user) Update an existing user reference
-
Field Details
-
PROVIDER_NAME
- See Also:
-
USERNAME
Username constant used in JSON formatted users- See Also:
-
ROLES
Role constant used in JSON formatted users- See Also:
-
ENCODING
Encoding expected from all inputs- See Also:
-
securityService
protected org.opencastproject.security.api.SecurityService securityServiceThe security service -
groupRoleProvider
Group Role provider -
roleProvider
Role provider -
nullToken
A token to store in the miss cache -
emf
protected javax.persistence.EntityManagerFactory emfThe 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
- 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
- Specified by:
getNamein interfaceorg.opencastproject.security.api.UserProvider
-
toString
-
getRolesForUser
- Specified by:
getRolesForUserin interfaceorg.opencastproject.security.api.RoleProvider- See Also:
-
findUsers
public Iterator<org.opencastproject.security.api.User> findUsers(String query, int offset, int limit) - Specified by:
findUsersin interfaceorg.opencastproject.security.api.UserProvider- See Also:
-
findUsers
- Specified by:
findUsersin interfaceorg.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:
findRolesin interfaceorg.opencastproject.security.api.RoleProvider- See Also:
-
loadUser
Load a user by userName- Specified by:
loadUserin interfaceorg.opencastproject.security.api.UserProvider- Specified by:
loadUserin interfaceUserReferenceProvider- Parameters:
userName-- Returns:
- the user or
nullif not found - See Also:
-
getUsers
- Specified by:
getUsersin interfaceorg.opencastproject.security.api.UserProvider
-
getRoles
Return the roles- Returns:
- the roles
-
getOrganization
- Specified by:
getOrganizationin interfaceorg.opencastproject.security.api.RoleProvider- Specified by:
getOrganizationin interfaceorg.opencastproject.security.api.UserProvider- See Also:
-
addUserReference
public void addUserReference(org.opencastproject.security.impl.jpa.JpaUserReference user, String mechanism) Add a user reference- Specified by:
addUserReferencein interfaceUserReferenceProvider- Parameters:
user- the user reference to be addedmechanism- 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:
updateUserReferencein interfaceUserReferenceProvider- 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:
findUserReferencein interfaceUserReferenceProvider- Parameters:
userName- the user nameorganizationId- the organization id- Returns:
- the user or
nullif not found
-
countUsers
public long countUsers()- Specified by:
countUsersin interfaceorg.opencastproject.security.api.UserProvider
-
invalidate
- Specified by:
invalidatein interfaceorg.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 deleteorgId- the organization id- Throws:
org.opencastproject.util.NotFoundException- if the requested user is not existorg.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:UserReferenceProviderSet an optional roleProvider that takes care about resolving roles- Specified by:
setRoleProviderin interfaceUserReferenceProvider- Parameters:
roleProvider-
-