Class JpaGroupRoleProvider
java.lang.Object
org.opencastproject.userdirectory.JpaGroupRoleProvider
- All Implemented Interfaces:
org.opencastproject.security.api.GroupProvider,org.opencastproject.security.api.RoleProvider,AAIRoleProvider,GroupRoleProvider
public class JpaGroupRoleProvider
extends Object
implements AAIRoleProvider, org.opencastproject.security.api.GroupProvider, GroupRoleProvider
Manages and locates users using JPA.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.opencastproject.db.DBSessionprotected org.opencastproject.db.DBSessionFactoryprotected javax.persistence.EntityManagerFactoryThe factory used to generate the entity managerprotected org.opencastproject.security.api.OrganizationDirectoryServiceThe organization directory servicestatic final StringThe JPA persistence unit nameprotected org.opencastproject.security.api.SecurityServiceThe security serviceprotected org.opencastproject.security.api.UserDirectoryServiceThe user directory service -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) Callback for activation of this component.voidaddGroup(org.opencastproject.security.impl.jpa.JpaGroup group) Adds or updates a group to the persistence.booleanaddMemberToGroup(String groupId, String member) Add member to group.longcountTotalGroups(Optional<String> nameFilter, Optional<String> roleFilter, Optional<String> textFilter) Count groups that fit the filter criteria in total.voidcreateGroup(String name, String description, String roles, String users) Create a new groupIterator<org.opencastproject.security.api.Role> org.opencastproject.security.impl.jpa.JpaGroupGet group.Iterator<org.opencastproject.security.api.Group> Getting all groupsorg.opencastproject.security.api.JaxbGroupListgetGroups(int limit, int offset) Returns a XML representation of the list of groups available the current user's organization.List<org.opencastproject.security.impl.jpa.JpaGroup> getGroups(Optional<Integer> limit, Optional<Integer> offset, Optional<String> nameFilter, Optional<String> roleFilter, Optional<String> textFilter, ArrayList<org.opencastproject.util.requests.SortCriterion> sortCriteria) Get groups by the defined filter and sorting criteria.Iterator<org.opencastproject.security.api.Role> getRoles()Return the rolesList<org.opencastproject.security.api.Role> getRolesForGroup(String groupName) List<org.opencastproject.security.api.Role> getRolesForUser(String userName) org.opencastproject.security.impl.jpa.JpaGroupLoads a group from persistencevoidremoveGroup(String groupId) Remove a group by idvoidremoveMemberFromAllGroups(String userName, String orgId) Removes a user from all groupsbooleanremoveMemberFromGroup(String groupId, String member) Remove member from group.voidsetDBSessionFactory(org.opencastproject.db.DBSessionFactory dbSessionFactory) voidsetEntityManagerFactory(javax.persistence.EntityManagerFactory emf) OSGi DIvoidsetOrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService organizationDirectoryService) voidsetSecurityService(org.opencastproject.security.api.SecurityService securityService) voidsetUserDirectoryService(org.opencastproject.security.api.UserDirectoryService userDirectoryService) Sets the user directory servicevoidUpdate a groupvoidupdateGroupMembershipFromRoles(String userName, String orgId, List<String> roleList) Updates a user's group membershipvoidUpdates a user's group membership
-
Field Details
-
PERSISTENCE_UNIT
The JPA persistence unit name- See Also:
-
securityService
protected org.opencastproject.security.api.SecurityService securityServiceThe security service -
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 -
organizationDirectoryService
protected org.opencastproject.security.api.OrganizationDirectoryService organizationDirectoryServiceThe organization directory service -
userDirectoryService
protected org.opencastproject.security.api.UserDirectoryService userDirectoryServiceThe user directory service
-
-
Constructor Details
-
JpaGroupRoleProvider
public JpaGroupRoleProvider()
-
-
Method Details
-
setEntityManagerFactory
public void setEntityManagerFactory(javax.persistence.EntityManagerFactory emf) OSGi DI -
setDBSessionFactory
public void setDBSessionFactory(org.opencastproject.db.DBSessionFactory dbSessionFactory) -
setUserDirectoryService
public void setUserDirectoryService(org.opencastproject.security.api.UserDirectoryService userDirectoryService) Sets the user directory service- Parameters:
userDirectoryService- the userDirectoryService to set
-
setSecurityService
public void setSecurityService(org.opencastproject.security.api.SecurityService securityService) - Parameters:
securityService- the securityService to set
-
setOrganizationDirectoryService
public void setOrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService organizationDirectoryService) - Parameters:
organizationDirectoryService- the organizationDirectoryService to set
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) Callback for activation of this component.- Parameters:
cc- the component context
-
getRoles
Return the roles- Specified by:
getRolesin interfaceAAIRoleProvider- Returns:
- the roles
- See Also:
-
getRolesForUser
- Specified by:
getRolesForUserin interfaceGroupRoleProvider- Specified by:
getRolesForUserin interfaceorg.opencastproject.security.api.RoleProvider- See Also:
-
getRolesForGroup
- Specified by:
getRolesForGroupin interfaceorg.opencastproject.security.api.GroupProvider- Specified by:
getRolesForGroupin interfaceGroupRoleProvider- See Also:
-
getOrganization
- Specified by:
getOrganizationin interfaceGroupRoleProvider- Specified by:
getOrganizationin interfaceorg.opencastproject.security.api.RoleProvider- See Also:
-
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:
-
updateGroupMembershipFromRoles
Updates a user's group membership- Specified by:
updateGroupMembershipFromRolesin interfaceGroupRoleProvider- Parameters:
userName- the usernameorgId- the user's organizationroleList- the list of group role names
-
updateGroupMembershipFromRoles
public void updateGroupMembershipFromRoles(String userName, String orgId, List<String> roleList, String prefix) Updates a user's group membership- Parameters:
userName- the usernameorgId- the user's organizationroleList- the list of group role namesprefix- handle only roles with given prefix
-
removeMemberFromAllGroups
Removes a user from all groups- Parameters:
userName- the usernameorgId- the user's organization
-
loadGroup
Loads a group from persistence- Parameters:
groupId- the group idorgId- the organization id- Returns:
- the loaded group or
nullif not found
-
getGroup
Get group.- Parameters:
groupId-- Returns:
- the group
-
addGroup
public void addGroup(org.opencastproject.security.impl.jpa.JpaGroup group) throws org.opencastproject.security.api.UnauthorizedException Adds or updates a group to the persistence.- Specified by:
addGroupin interfaceGroupRoleProvider- Parameters:
group- the group to add- Throws:
org.opencastproject.security.api.UnauthorizedException
-
getGroups
Description copied from interface:GroupRoleProviderGetting all groups- Specified by:
getGroupsin interfaceGroupRoleProvider- Returns:
- Iterator<Group> persisted groups
-
getGroups
public org.opencastproject.security.api.JaxbGroupList getGroups(int limit, int offset) throws IOException Returns a XML representation of the list of groups available the current user's organization.- Parameters:
limit- the int amount to limit the resultsoffset- the offset to start this result set at- Returns:
- the JaxbGroupList of results
- Throws:
IOException- if unexpected IO exception occurs
-
getGroups
public List<org.opencastproject.security.impl.jpa.JpaGroup> getGroups(Optional<Integer> limit, Optional<Integer> offset, Optional<String> nameFilter, Optional<String> roleFilter, Optional<String> textFilter, ArrayList<org.opencastproject.util.requests.SortCriterion> sortCriteria) Get groups by the defined filter and sorting criteria.- Parameters:
limit- how many groups to get (optional)offset- where to start the list for pagination (optional)nameFilter- filter by group name (optional)textFilter- fulltext filter (optional)sortCriteria- the sorting criteria- Returns:
- a list of groups
-
countTotalGroups
public long countTotalGroups(Optional<String> nameFilter, Optional<String> roleFilter, Optional<String> textFilter) Count groups that fit the filter criteria in total.- Parameters:
nameFilter- filter by group name (optional)textFilter- fulltext filter (optional)- Returns:
- a list of groups
-
removeGroup
public void removeGroup(String groupId) throws org.opencastproject.util.NotFoundException, org.opencastproject.security.api.UnauthorizedException, Exception Remove a group by id- Parameters:
groupId- the id of the group to remove- Throws:
Exception- unexpected error occurredorg.opencastproject.security.api.UnauthorizedException- user is not authorized to remove this grouporg.opencastproject.util.NotFoundException- the group was not found
-
createGroup
public void createGroup(String name, String description, String roles, String users) throws IllegalArgumentException, org.opencastproject.security.api.UnauthorizedException, ConflictException Create a new group- Parameters:
name- the name of the groupdescription- a description of the grouproles- the roles of the groupusers- the users in the group- Throws:
IllegalArgumentException- if missing or bad parametersorg.opencastproject.security.api.UnauthorizedException- if user does not have rights to create groupConflictException- if group already exists
-
removeMemberFromGroup
public boolean removeMemberFromGroup(String groupId, String member) throws org.opencastproject.util.NotFoundException, org.opencastproject.security.api.UnauthorizedException Remove member from group.- Parameters:
groupId-member-- Returns:
- true if we updated the group, false otherwise
- Throws:
org.opencastproject.util.NotFoundExceptionorg.opencastproject.security.api.UnauthorizedException
-
addMemberToGroup
public boolean addMemberToGroup(String groupId, String member) throws org.opencastproject.util.NotFoundException, org.opencastproject.security.api.UnauthorizedException Add member to group.- Parameters:
groupId-member-- Returns:
- true if we updated the group, false otherwise
- Throws:
org.opencastproject.util.NotFoundExceptionorg.opencastproject.security.api.UnauthorizedException
-
updateGroup
public void updateGroup(String groupId, String name, String description, String roles, String users) throws org.opencastproject.util.NotFoundException, org.opencastproject.security.api.UnauthorizedException Update a group- Specified by:
updateGroupin interfaceGroupRoleProvider- Parameters:
groupId- the id of the group to updatename- the name to updatedescription- the description to updateroles- the roles to updateusers- the users to update- Throws:
org.opencastproject.util.NotFoundException- if the group is not foundorg.opencastproject.security.api.UnauthorizedException- if the user does not have rights to update the group- See Also:
-