Class JpaUserReferenceProvider
java.lang.Object
org.opencastproject.userdirectory.JpaUserReferenceProvider
- All Implemented Interfaces:
RoleProvider,UserProvider,UserReferenceProvider
public class JpaUserReferenceProvider
extends Object
implements UserReferenceProvider, UserProvider, RoleProvider
Manages and locates users references using JPA.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DBSessionprotected 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 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(JpaUserReference user, String mechanism) Add a user referencelongReturns the number of users in the providervoiddeleteUser(String username, String orgId) Delete the given userfindRoles(String query, Role.Target target, int offset, int limit) Return the found roles as an iterator.findUserReference(String userName, String organizationId) Returns the persisted user reference by the user name and organization idReturn the found user's as an iterator.findUsers(Collection<String> userNames) Find a list of users by their user names Note that the default implementation of this might be slow, as it callsloadUseron every single user.getName()Gets the provider nameReturns the identifier for the organization that is associated with this user provider.getRoles()Return the rolesgetRolesForUser(String userName) Returns the roles for this user or an empty array if no roles are applicable.getUsers()Gets all known users.voidinvalidate(String userName) Discards any cached value for given user name.Load a user by userNamevoidsetDBSessionFactory(DBSessionFactory dbSessionFactory) voidsetGroupRoleProvider(JpaGroupRoleProvider groupRoleProvider) voidsetRoleProvider(RoleProvider roleProvider) Set an optional roleProvider that takes care about resolving rolesvoidsetSecurityService(SecurityService securityService) toString()voidUpdate 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
The 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
-
db
-
-
Constructor Details
-
JpaUserReferenceProvider
public JpaUserReferenceProvider()
-
-
Method Details
-
setDBSessionFactory
-
setSecurityService
- 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
Description copied from interface:UserProviderGets the provider name- Specified by:
getNamein interfaceUserProvider- Returns:
- the provider name
-
toString
-
getRolesForUser
Returns the roles for this user or an empty array if no roles are applicable.- Specified by:
getRolesForUserin interfaceRoleProvider- Parameters:
userName- the user id- Returns:
- the set of roles
- See Also:
-
findUsers
Return the found user's as an iterator.- Specified by:
findUsersin interfaceUserProvider- 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
- See Also:
-
findUsers
Description copied from interface:UserProviderFind a list of users by their user names Note that the default implementation of this might be slow, as it callsloadUseron every single user.- Specified by:
findUsersin interfaceUserProvider- Parameters:
userNames- A list of user names- Returns:
- A list of resolved user objects
-
findRoles
Return the found roles as an iterator.- Specified by:
findRolesin interfaceRoleProvider- 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 role's
- See Also:
-
loadUser
Load a user by userName- Specified by:
loadUserin interfaceUserProvider- Specified by:
loadUserin interfaceUserReferenceProvider- Parameters:
userName-- Returns:
- the user or
nullif not found - See Also:
-
getUsers
Description copied from interface:UserProviderGets all known users.- Specified by:
getUsersin interfaceUserProvider- Returns:
- the users
-
getRoles
Return the roles- Returns:
- the roles
-
getOrganization
Returns the identifier for the organization that is associated with this user provider. If equal toUserProvider.ALL_ORGANIZATIONS, this provider will always be consulted, regardless of the organization.- Specified by:
getOrganizationin interfaceRoleProvider- Specified by:
getOrganizationin interfaceUserProvider- Returns:
- the defining organization
- See Also:
-
addUserReference
Add a user reference- Specified by:
addUserReferencein interfaceUserReferenceProvider- Parameters:
user- the user reference to be addedmechanism- the mechanism that adds the user reference
-
updateUserReference
Update an existing user reference- Specified by:
updateUserReferencein interfaceUserReferenceProvider- Parameters:
user- the user reference to be updated
-
findUserReference
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()Description copied from interface:UserProviderReturns the number of users in the provider- Specified by:
countUsersin interfaceUserProvider- Returns:
- the count of users in the provider
-
invalidate
Description copied from interface:UserProviderDiscards any cached value for given user name.- Specified by:
invalidatein interfaceUserProvider- Parameters:
userName- the user name
-
deleteUser
public void deleteUser(String username, String orgId) throws NotFoundException, UnauthorizedException, Exception Delete the given user- Parameters:
username- the name of the user to deleteorgId- the organization id- Throws:
NotFoundException- if the requested user is not existUnauthorizedException- if you havn't permissions to delete an admin user (only admins may do that)Exception
-
setRoleProvider
Description copied from interface:UserReferenceProviderSet an optional roleProvider that takes care about resolving roles- Specified by:
setRoleProviderin interfaceUserReferenceProvider- Parameters:
roleProvider-
-