@Service(value="permissionAwareCrudService") public class PermissionAwareCrudService<E extends PersistentObject,D extends GenericHibernateDao<E,Integer>> extends AbstractCrudService<E,D>
AbstractCrudService| Modifier and Type | Field and Description |
|---|---|
protected PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>> |
permissionCollectionService |
dao, logger| Modifier | Constructor and Description |
|---|---|
|
PermissionAwareCrudService()
Default constructor, which calls the type-constructor
|
protected |
PermissionAwareCrudService(Class<E> entityClass)
Constructor that sets the concrete entity class for the service.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAndSaveGroupPermissions(E entity,
UserGroup userGroup,
Permission... permissions)
This method adds (user) permissions to the passed entity and persists (!)
|
void |
addAndSaveUserPermissions(E entity,
User user,
Permission... permissions)
This method adds (user) permissions to the passed entity and persists (!)
|
Map<PersistentObject,PermissionCollection> |
findAllUserGroupPermissionsOfUserGroup(UserGroup userGroup)
This method returns a
Map that maps PersistentObjects
to PermissionCollections for the passed UserGroup. |
Map<PersistentObject,PermissionCollection> |
findAllUserPermissionsOfUser(User user)
|
PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>> |
getPermissionCollectionService() |
void |
removeAndSaveGroupPermissions(E entity,
UserGroup userGroup,
Permission... permissions)
This method removes (group) permissions from the passed entity and persists (!)
|
void |
removeAndSaveUserPermissions(E entity,
User user,
Permission... permissions)
This method removes (user) permissions from the passed entity and persists (!)
|
void |
setDao(D dao)
Subclasses must implement this class and annotate it with
Autowired and Qualifier! |
void |
setPermissionCollectionService(PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>> permissionCollectionService) |
delete, findAll, findAllRestricted, findAllWhereFieldEquals, findAllWithCollectionContaining, findById, findBySimpleFilter, loadById, saveOrUpdate, updatePartialWithJsonNodegetDao, getEntityClass@Autowired @Qualifier(value="permissionCollectionService") protected PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>> permissionCollectionService
public PermissionAwareCrudService()
@Autowired @Qualifier(value="genericDao") public void setDao(D dao)
AbstractDaoServiceAutowired and Qualifier! This is necessary as there may
be multiple candidates to autowire (due to hierarchy) and we have to
configure the correct ones.setDao in class AbstractDaoService<E extends PersistentObject,D extends GenericHibernateDao<E,Integer>>dao - the dao to setpublic void addAndSaveUserPermissions(E entity, User user, Permission... permissions)
entity - The secured entityuser - The user that gets permissions for the entitypermissions - The permissions the user gets for the entitypublic void removeAndSaveUserPermissions(E entity, User user, Permission... permissions)
entity - The secured entityuser - The user from which the permissions for the entity will be removedpermissions - The permissions to removepublic void addAndSaveGroupPermissions(E entity, UserGroup userGroup, Permission... permissions)
entity - The secured entityuserGroup - The user group that gets permissions for the entitypermissions - The permissions the user group gets for the entitypublic void removeAndSaveGroupPermissions(E entity, UserGroup userGroup, Permission... permissions)
entity - The secured entityuserGroup - The user group from which the permissions for the entity will be removedpermissions - The permissions to remove@PreAuthorize(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#user, \'READ\')") @Transactional(readOnly=true) public Map<PersistentObject,PermissionCollection> findAllUserPermissionsOfUser(User user)
Map that maps PersistentObjects
to PermissionCollections for the passed User. I.e. the keySet
of the map is the collection of all PersistentObjects where the
user has at least one permission and the corresponding value contains
the PermissionCollection for the passed user on the entity.user - @PreAuthorize(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#userGroup, \'READ\')") @Transactional(readOnly=true) public Map<PersistentObject,PermissionCollection> findAllUserGroupPermissionsOfUserGroup(UserGroup userGroup)
Map that maps PersistentObjects
to PermissionCollections for the passed UserGroup. I.e. the keySet
of the map is the collection of all PersistentObjects where the
user group has at least one permission and the corresponding value contains
the PermissionCollection for the passed user group on the entity.userGroup - public PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>> getPermissionCollectionService()
public void setPermissionCollectionService(PermissionCollectionService<PermissionCollection,PermissionCollectionDao<PermissionCollection>> permissionCollectionService)
permissionCollectionService - the permissionCollectionService to setCopyright © 2020 terrestris GmbH & Co. KG. All rights reserved.