CCM NG:
- Renamed privilege constants in ccm-core to match naming convention (constants for privilege should start with "PRIVILEGE_") - Added method PermissionsManager#listDefiniedPrivileges(Class) which lists all privileges constants definied in a class. git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4352 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
b674042e34
commit
10d5c57271
|
|
@ -120,7 +120,7 @@ public class GlobalNavigation extends SimpleComponent {
|
||||||
|
|
||||||
/* If the current user has admin permissions, insert a link to the admin center */
|
/* If the current user has admin permissions, insert a link to the admin center */
|
||||||
if (CdiUtil.createCdiUtil().findBean(PermissionChecker.class)
|
if (CdiUtil.createCdiUtil().findBean(PermissionChecker.class)
|
||||||
.isPermitted(CoreConstants.ADMIN_PRIVILEGE)) {
|
.isPermitted(CoreConstants.PRIVILEGE_ADMIN)) {
|
||||||
link(sreq, nav, "cms:adminCenter", m_adminPath, adminTitle);
|
link(sreq, nav, "cms:adminCenter", m_adminPath, adminTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ public class ContentSectionManager {
|
||||||
* @return The new content section.
|
* @return The new content section.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public ContentSection createContentSection(final String name) {
|
public ContentSection createContentSection(final String name) {
|
||||||
if (name == null || name.isEmpty()) {
|
if (name == null || name.isEmpty()) {
|
||||||
|
|
@ -191,7 +191,7 @@ public class ContentSectionManager {
|
||||||
* @@param name The new name of the content section.
|
* @@param name The new name of the content section.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void renameContentSection(final ContentSection section,
|
public void renameContentSection(final ContentSection section,
|
||||||
final String name) {
|
final String name) {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public class ContentSectionRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void save(final ContentSection section) {
|
public void save(final ContentSection section) {
|
||||||
|
|
@ -75,7 +75,7 @@ public class ContentSectionRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void delete(final ContentSection section) {
|
public void delete(final ContentSection section) {
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ package org.libreccm.categorization;
|
||||||
public final class CategorizationConstants {
|
public final class CategorizationConstants {
|
||||||
|
|
||||||
public static final String CAT_XML_NS = "http://categorization.libreccm.org";
|
public static final String CAT_XML_NS = "http://categorization.libreccm.org";
|
||||||
public static final String MANAGE_CATEGORY_PRIVILEGE = "manage_category";
|
public static final String PRIVILEGE_MANAGE_CATEGORY = "manage_category";
|
||||||
public static final String MANAGE_CATEGORY_OBJECTS_PRIVILEGE
|
public static final String PRIVILEGE_MANAGE_CATEGORY_OBJECTS
|
||||||
= "manage_category_objects";
|
= "manage_category_objects";
|
||||||
public static final String MANAGE_DOMAINS_PRIVILEGE = "manage_domains";
|
public static final String PRIVILEGE_MANAGE_DOMAINS = "manage_domains";
|
||||||
|
|
||||||
private CategorizationConstants() {
|
private CategorizationConstants() {
|
||||||
//Nothing
|
//Nothing
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ public class CategoryManager {
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void addObjectToCategory(
|
public void addObjectToCategory(
|
||||||
final CcmObject object,
|
final CcmObject object,
|
||||||
@RequiresPrivilege(MANAGE_CATEGORY_OBJECTS_PRIVILEGE)
|
@RequiresPrivilege(PRIVILEGE_MANAGE_CATEGORY_OBJECTS)
|
||||||
final Category category) {
|
final Category category) {
|
||||||
|
|
||||||
addObjectToCategory(object, category, null);
|
addObjectToCategory(object, category, null);
|
||||||
|
|
@ -121,7 +121,7 @@ public class CategoryManager {
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void addObjectToCategory(
|
public void addObjectToCategory(
|
||||||
final CcmObject object,
|
final CcmObject object,
|
||||||
@RequiresPrivilege(MANAGE_CATEGORY_OBJECTS_PRIVILEGE)
|
@RequiresPrivilege(PRIVILEGE_MANAGE_CATEGORY_OBJECTS)
|
||||||
final Category category,
|
final Category category,
|
||||||
final String type) {
|
final String type) {
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ public class CategoryManager {
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void removeObjectFromCategory(
|
public void removeObjectFromCategory(
|
||||||
final CcmObject object,
|
final CcmObject object,
|
||||||
@RequiresPrivilege(MANAGE_CATEGORY_OBJECTS_PRIVILEGE)
|
@RequiresPrivilege(PRIVILEGE_MANAGE_CATEGORY_OBJECTS)
|
||||||
final Category category)
|
final Category category)
|
||||||
throws ObjectNotAssignedToCategoryException {
|
throws ObjectNotAssignedToCategoryException {
|
||||||
|
|
||||||
|
|
@ -252,7 +252,7 @@ public class CategoryManager {
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void increaseObjectOrder(
|
public void increaseObjectOrder(
|
||||||
final CcmObject object,
|
final CcmObject object,
|
||||||
@RequiresPrivilege(MANAGE_CATEGORY_OBJECTS_PRIVILEGE)
|
@RequiresPrivilege(PRIVILEGE_MANAGE_CATEGORY_OBJECTS)
|
||||||
final Category category)
|
final Category category)
|
||||||
throws ObjectNotAssignedToCategoryException {
|
throws ObjectNotAssignedToCategoryException {
|
||||||
|
|
||||||
|
|
@ -326,7 +326,7 @@ public class CategoryManager {
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void decreaseObjectOrder(
|
public void decreaseObjectOrder(
|
||||||
final CcmObject object,
|
final CcmObject object,
|
||||||
@RequiresPrivilege(MANAGE_CATEGORY_OBJECTS_PRIVILEGE)
|
@RequiresPrivilege(PRIVILEGE_MANAGE_CATEGORY_OBJECTS)
|
||||||
final Category category)
|
final Category category)
|
||||||
throws ObjectNotAssignedToCategoryException {
|
throws ObjectNotAssignedToCategoryException {
|
||||||
|
|
||||||
|
|
@ -417,7 +417,7 @@ public class CategoryManager {
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void addSubCategoryToCategory(
|
public void addSubCategoryToCategory(
|
||||||
final Category subCategory,
|
final Category subCategory,
|
||||||
@RequiresPrivilege(MANAGE_CATEGORY_PRIVILEGE)
|
@RequiresPrivilege(PRIVILEGE_MANAGE_CATEGORY)
|
||||||
final Category parentCategory) {
|
final Category parentCategory) {
|
||||||
|
|
||||||
final Category sub = categoryRepo.findById(subCategory.getObjectId());
|
final Category sub = categoryRepo.findById(subCategory.getObjectId());
|
||||||
|
|
@ -457,7 +457,7 @@ public class CategoryManager {
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void removeSubCategoryFromCategory(
|
public void removeSubCategoryFromCategory(
|
||||||
final Category subCategory,
|
final Category subCategory,
|
||||||
@RequiresPrivilege(MANAGE_CATEGORY_PRIVILEGE)
|
@RequiresPrivilege(PRIVILEGE_MANAGE_CATEGORY)
|
||||||
final Category parentCategory) {
|
final Category parentCategory) {
|
||||||
|
|
||||||
if (subCategory.getParentCategory() == null
|
if (subCategory.getParentCategory() == null
|
||||||
|
|
@ -502,7 +502,7 @@ public class CategoryManager {
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void increaseCategoryOrder(
|
public void increaseCategoryOrder(
|
||||||
final Category subCategory,
|
final Category subCategory,
|
||||||
@RequiresPrivilege(MANAGE_CATEGORY_PRIVILEGE)
|
@RequiresPrivilege(PRIVILEGE_MANAGE_CATEGORY)
|
||||||
final Category parentCategory) {
|
final Category parentCategory) {
|
||||||
|
|
||||||
if (parentCategory == null) {
|
if (parentCategory == null) {
|
||||||
|
|
@ -577,7 +577,7 @@ public class CategoryManager {
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void decreaseCategoryOrder(
|
public void decreaseCategoryOrder(
|
||||||
final Category subCategory,
|
final Category subCategory,
|
||||||
@RequiresPrivilege(MANAGE_CATEGORY_PRIVILEGE)
|
@RequiresPrivilege(PRIVILEGE_MANAGE_CATEGORY)
|
||||||
final Category parentCategory) {
|
final Category parentCategory) {
|
||||||
|
|
||||||
if (parentCategory == null) {
|
if (parentCategory == null) {
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ public class CategoryRepository extends AbstractEntityRepository<Long, Category>
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void save(
|
public void save(
|
||||||
@RequiresPrivilege(CategorizationConstants.MANAGE_CATEGORY_PRIVILEGE)
|
@RequiresPrivilege(CategorizationConstants.PRIVILEGE_MANAGE_CATEGORY)
|
||||||
final Category category) {
|
final Category category) {
|
||||||
|
|
||||||
super.save(category);
|
super.save(category);
|
||||||
|
|
@ -181,7 +181,7 @@ public class CategoryRepository extends AbstractEntityRepository<Long, Category>
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void delete(
|
public void delete(
|
||||||
@RequiresPrivilege(CategorizationConstants.MANAGE_CATEGORY_PRIVILEGE)
|
@RequiresPrivilege(CategorizationConstants.PRIVILEGE_MANAGE_CATEGORY)
|
||||||
final Category category) {
|
final Category category) {
|
||||||
|
|
||||||
super.save(category);
|
super.save(category);
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class DomainManager {
|
||||||
* @return The new domain.
|
* @return The new domain.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CategorizationConstants.MANAGE_DOMAINS_PRIVILEGE)
|
@RequiresPrivilege(CategorizationConstants.PRIVILEGE_MANAGE_DOMAINS)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public Domain createDomain(final String domainKey,
|
public Domain createDomain(final String domainKey,
|
||||||
final String rootCategoryName) {
|
final String rootCategoryName) {
|
||||||
|
|
@ -95,7 +95,7 @@ public class DomainManager {
|
||||||
* {@code CcmApplication is added}.
|
* {@code CcmApplication is added}.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CategorizationConstants.MANAGE_DOMAINS_PRIVILEGE)
|
@RequiresPrivilege(CategorizationConstants.PRIVILEGE_MANAGE_DOMAINS)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void addDomainOwner(final CcmApplication application,
|
public void addDomainOwner(final CcmApplication application,
|
||||||
final Domain domain) {
|
final Domain domain) {
|
||||||
|
|
@ -124,7 +124,7 @@ public class DomainManager {
|
||||||
* {@code CcmApplication} should be removed.
|
* {@code CcmApplication} should be removed.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CategorizationConstants.MANAGE_DOMAINS_PRIVILEGE)
|
@RequiresPrivilege(CategorizationConstants.PRIVILEGE_MANAGE_DOMAINS)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void removeDomainOwner(final CcmApplication application,
|
public void removeDomainOwner(final CcmApplication application,
|
||||||
final Domain domain) {
|
final Domain domain) {
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CategorizationConstants.MANAGE_DOMAINS_PRIVILEGE)
|
@RequiresPrivilege(CategorizationConstants.PRIVILEGE_MANAGE_DOMAINS)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void save(final Domain domain) {
|
public void save(final Domain domain) {
|
||||||
|
|
@ -152,7 +152,7 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CategorizationConstants.MANAGE_DOMAINS_PRIVILEGE)
|
@RequiresPrivilege(CategorizationConstants.PRIVILEGE_MANAGE_DOMAINS)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void delete(final Domain domain) {
|
public void delete(final Domain domain) {
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ public class ConfigurationManager {
|
||||||
* {@link Configuration}.
|
* {@link Configuration}.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void saveConfiguration(final Object configuration) {
|
public void saveConfiguration(final Object configuration) {
|
||||||
if (configuration == null) {
|
if (configuration == null) {
|
||||||
|
|
@ -278,7 +278,7 @@ public class ConfigurationManager {
|
||||||
* @param value The value to set.
|
* @param value The value to set.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
private <T> void setSettingValue(final Object configuration,
|
private <T> void setSettingValue(final Object configuration,
|
||||||
final String settingName,
|
final String settingName,
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ public class SettingManager {
|
||||||
* @param setting The setting to save.
|
* @param setting The setting to save.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void saveSetting(final AbstractSetting<?> setting) {
|
public void saveSetting(final AbstractSetting<?> setting) {
|
||||||
if (setting.getSettingId() == 0) {
|
if (setting.getSettingId() == 0) {
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,12 @@ public final class CoreConstants {
|
||||||
/**
|
/**
|
||||||
* Constant for the {@code admin} privilege.
|
* Constant for the {@code admin} privilege.
|
||||||
*/
|
*/
|
||||||
public static final String ADMIN_PRIVILEGE = "admin";
|
public static final String PRIVILEGE_ADMIN = "admin";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant for the {@code system} privilege.
|
* Constant for the {@code system} privilege.
|
||||||
*/
|
*/
|
||||||
public static final String SYSTEM_PRIVILEGE = "system";
|
public static final String PRIVILEGE_SYSTEM = "system";
|
||||||
|
|
||||||
private CoreConstants() {
|
private CoreConstants() {
|
||||||
//Nothing
|
//Nothing
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ public class ChallengeManager {
|
||||||
* @return The text of the challenge mail.
|
* @return The text of the challenge mail.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public String createEmailVerification(final User user) {
|
public String createEmailVerification(final User user) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|
@ -129,7 +129,7 @@ public class ChallengeManager {
|
||||||
* user.
|
* user.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public void sendEmailVerification(final User user)
|
public void sendEmailVerification(final User user)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
final String text = createEmailVerification(user);
|
final String text = createEmailVerification(user);
|
||||||
|
|
@ -151,7 +151,7 @@ public class ChallengeManager {
|
||||||
* stored token.
|
* stored token.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public void finishEmailVerification(final User user,
|
public void finishEmailVerification(final User user,
|
||||||
final String submittedToken)
|
final String submittedToken)
|
||||||
throws ChallengeFailedException {
|
throws ChallengeFailedException {
|
||||||
|
|
@ -180,7 +180,7 @@ public class ChallengeManager {
|
||||||
* @return The challenge message.
|
* @return The challenge message.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public String createAccountActivation(final User user) {
|
public String createAccountActivation(final User user) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|
@ -198,7 +198,7 @@ public class ChallengeManager {
|
||||||
* message.
|
* message.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public void sendAccountActivation(final User user)
|
public void sendAccountActivation(final User user)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
final String text = createAccountActivation(user);
|
final String text = createAccountActivation(user);
|
||||||
|
|
@ -220,7 +220,7 @@ public class ChallengeManager {
|
||||||
* the stored token.
|
* the stored token.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public void finishAccountActivation(final User user,
|
public void finishAccountActivation(final User user,
|
||||||
final String submittedToken)
|
final String submittedToken)
|
||||||
throws ChallengeFailedException {
|
throws ChallengeFailedException {
|
||||||
|
|
@ -247,7 +247,7 @@ public class ChallengeManager {
|
||||||
* @return The challenge message.
|
* @return The challenge message.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public String createPasswordRecover(final User user) {
|
public String createPasswordRecover(final User user) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|
@ -266,7 +266,7 @@ public class ChallengeManager {
|
||||||
* message.
|
* message.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public void sendPasswordRecover(final User user)
|
public void sendPasswordRecover(final User user)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
final String text = createPasswordRecover(user);
|
final String text = createPasswordRecover(user);
|
||||||
|
|
@ -289,7 +289,7 @@ public class ChallengeManager {
|
||||||
* the stored token.
|
* the stored token.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public void finishPasswordRecover(final User user,
|
public void finishPasswordRecover(final User user,
|
||||||
final String submittedToken,
|
final String submittedToken,
|
||||||
final String newPassword)
|
final String newPassword)
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class GroupManager {
|
||||||
* @param group The group to which the user is added.
|
* @param group The group to which the user is added.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void addMemberToGroup(final User user, final Group group) {
|
public void addMemberToGroup(final User user, final Group group) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
@ -95,7 +95,7 @@ public class GroupManager {
|
||||||
* @param group The group from which the user is removed.
|
* @param group The group from which the user is removed.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void removeMemberFromGroup(final User member, final Group group) {
|
public void removeMemberFromGroup(final User member, final Group group) {
|
||||||
if (member == null) {
|
if (member == null) {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ public class GroupRepository extends AbstractEntityRepository<Long, Group> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void save(final Group group) {
|
public void save(final Group group) {
|
||||||
|
|
@ -101,7 +101,7 @@ public class GroupRepository extends AbstractEntityRepository<Long, Group> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void delete(final Group entity) {
|
public void delete(final Group entity) {
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ public class OneTimeAuthManager {
|
||||||
* @return The one time authentication token with the not hashed token.
|
* @return The one time authentication token with the not hashed token.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public OneTimeAuthToken createForUser(
|
public OneTimeAuthToken createForUser(
|
||||||
final User user, final OneTimeAuthTokenPurpose purpose) {
|
final User user, final OneTimeAuthTokenPurpose purpose) {
|
||||||
|
|
@ -148,7 +148,7 @@ public class OneTimeAuthManager {
|
||||||
* {@code null} if there is no such token.
|
* {@code null} if there is no such token.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public List<OneTimeAuthToken> retrieveForUser(
|
public List<OneTimeAuthToken> retrieveForUser(
|
||||||
final User user, final OneTimeAuthTokenPurpose purpose) {
|
final User user, final OneTimeAuthTokenPurpose purpose) {
|
||||||
if (user == null || purpose == null) {
|
if (user == null || purpose == null) {
|
||||||
|
|
@ -177,7 +177,7 @@ public class OneTimeAuthManager {
|
||||||
* purpose, {@code false} if not.
|
* purpose, {@code false} if not.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public boolean validTokenExistsForUser(
|
public boolean validTokenExistsForUser(
|
||||||
final User user, final OneTimeAuthTokenPurpose purpose) {
|
final User user, final OneTimeAuthTokenPurpose purpose) {
|
||||||
if (user == null || purpose == null) {
|
if (user == null || purpose == null) {
|
||||||
|
|
@ -209,7 +209,7 @@ public class OneTimeAuthManager {
|
||||||
* @return {@code true} if the token is valid, {@code false} if not.
|
* @return {@code true} if the token is valid, {@code false} if not.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public boolean isValid(final OneTimeAuthToken token) {
|
public boolean isValid(final OneTimeAuthToken token) {
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
throw new IllegalArgumentException("Can't validate a token null");
|
throw new IllegalArgumentException("Can't validate a token null");
|
||||||
|
|
@ -234,7 +234,7 @@ public class OneTimeAuthManager {
|
||||||
* {@code false} if not.
|
* {@code false} if not.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public boolean verify(final OneTimeAuthToken token,
|
public boolean verify(final OneTimeAuthToken token,
|
||||||
final String submittedToken) {
|
final String submittedToken) {
|
||||||
if (token == null || submittedToken == null) {
|
if (token == null || submittedToken == null) {
|
||||||
|
|
@ -265,7 +265,7 @@ public class OneTimeAuthManager {
|
||||||
* @param token The token to invalidate.
|
* @param token The token to invalidate.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void invalidate(final OneTimeAuthToken token) {
|
public void invalidate(final OneTimeAuthToken token) {
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ public class PartyRepository extends AbstractEntityRepository<Long, Party> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void save(final Party party) {
|
public void save(final Party party) {
|
||||||
|
|
@ -85,7 +85,7 @@ public class PartyRepository extends AbstractEntityRepository<Long, Party> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void delete(final Party party) {
|
public void delete(final Party party) {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,13 @@ import javax.persistence.TypedQuery;
|
||||||
import org.libreccm.core.CcmObject;
|
import org.libreccm.core.CcmObject;
|
||||||
import org.libreccm.core.CoreConstants;
|
import org.libreccm.core.CoreConstants;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
|
@ -69,7 +76,7 @@ public class PermissionManager {
|
||||||
* @param object The object on which the privilege is granted.
|
* @param object The object on which the privilege is granted.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void grantPrivilege(final String privilege,
|
public void grantPrivilege(final String privilege,
|
||||||
final Role grantee,
|
final Role grantee,
|
||||||
|
|
@ -107,7 +114,7 @@ public class PermissionManager {
|
||||||
* @param grantee The role to which the privilege is granted.
|
* @param grantee The role to which the privilege is granted.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void grantPrivilege(final String privilege,
|
public void grantPrivilege(final String privilege,
|
||||||
final Role grantee) {
|
final Role grantee) {
|
||||||
|
|
@ -140,7 +147,7 @@ public class PermissionManager {
|
||||||
* @param object The object on which the privilege was granted.
|
* @param object The object on which the privilege was granted.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void revokePrivilege(final String privilege,
|
public void revokePrivilege(final String privilege,
|
||||||
final Role grantee,
|
final Role grantee,
|
||||||
|
|
@ -181,7 +188,7 @@ public class PermissionManager {
|
||||||
* @param grantee The role to which the privilege was granted.
|
* @param grantee The role to which the privilege was granted.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void revokePrivilege(final String privilege,
|
public void revokePrivilege(final String privilege,
|
||||||
final Role grantee) {
|
final Role grantee) {
|
||||||
|
|
@ -218,7 +225,7 @@ public class PermissionManager {
|
||||||
* @param target
|
* @param target
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void copyPermissions(final CcmObject source,
|
public void copyPermissions(final CcmObject source,
|
||||||
final CcmObject target) {
|
final CcmObject target) {
|
||||||
|
|
@ -244,6 +251,25 @@ public class PermissionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> listDefiniedPrivileges(final Class<?> clazz) {
|
||||||
|
return Arrays.stream(clazz.getDeclaredFields())
|
||||||
|
.filter(field -> Modifier.isStatic(field.getModifiers())
|
||||||
|
&& Modifier.isFinal(field.getModifiers()))
|
||||||
|
.filter(field -> field.getName().startsWith("PRIVILEGE_")
|
||||||
|
|| clazz.getSimpleName().endsWith("Privileges"))
|
||||||
|
.map(field -> getPrivilegeString(field))
|
||||||
|
.sorted()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPrivilegeString(final Field field) {
|
||||||
|
try {
|
||||||
|
return (String) field.get(null);
|
||||||
|
} catch (IllegalArgumentException | IllegalAccessException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a permission granting the provided {@code privilege} on the
|
* Checks if a permission granting the provided {@code privilege} on the
|
||||||
* provided {@code object} to the provided {@code role} exists.
|
* provided {@code object} to the provided {@code role} exists.
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ public class RegistrationManager {
|
||||||
* @throws IllegalArgumentException If the provided {@code user} is
|
* @throws IllegalArgumentException If the provided {@code user} is
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.SYSTEM_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_SYSTEM)
|
||||||
public void registerUser(final String userName,
|
public void registerUser(final String userName,
|
||||||
final String familyName,
|
final String familyName,
|
||||||
final String givenName,
|
final String givenName,
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class RoleManager {
|
||||||
* @param party The party which to which to role is assigned.
|
* @param party The party which to which to role is assigned.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void assignRoleToParty(final Role role, final Party party) {
|
public void assignRoleToParty(final Role role, final Party party) {
|
||||||
if (role == null) {
|
if (role == null) {
|
||||||
|
|
@ -92,7 +92,7 @@ public class RoleManager {
|
||||||
* @param party
|
* @param party
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void removeRoleFromParty(final Role role, final Party party) {
|
public void removeRoleFromParty(final Role role, final Party party) {
|
||||||
if (role == null) {
|
if (role == null) {
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ public class RoleRepository extends AbstractEntityRepository<Long, Role> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void save(final Role role) {
|
public void save(final Role role) {
|
||||||
|
|
@ -150,7 +150,7 @@ public class RoleRepository extends AbstractEntityRepository<Long, Role> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Override
|
@Override
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void delete(final Role role) {
|
public void delete(final Role role) {
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ public class UserManager {
|
||||||
* @return The new user.
|
* @return The new user.
|
||||||
*/
|
*/
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@ValidateOnExecution
|
@ValidateOnExecution
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public User createUser(final String givenName,
|
public User createUser(final String givenName,
|
||||||
|
|
@ -142,7 +142,7 @@ public class UserManager {
|
||||||
user.setPassword(hashPassword(newPassword));
|
user.setPassword(hashPassword(newPassword));
|
||||||
shiro.getSystemUser().execute(() -> userRepository.save(user));
|
shiro.getSystemUser().execute(() -> userRepository.save(user));
|
||||||
} else {
|
} else {
|
||||||
permissionChecker.checkPermission(CoreConstants.ADMIN_PRIVILEGE);
|
permissionChecker.checkPermission(CoreConstants.PRIVILEGE_ADMIN);
|
||||||
user.setPassword(hashPassword(newPassword));
|
user.setPassword(hashPassword(newPassword));
|
||||||
shiro.getSystemUser().execute(() -> userRepository.save(user));
|
shiro.getSystemUser().execute(() -> userRepository.save(user));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ public class UserRepository extends AbstractEntityRepository<Long, User> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void save(final User entity) {
|
public void save(final User entity) {
|
||||||
|
|
@ -170,7 +170,7 @@ public class UserRepository extends AbstractEntityRepository<Long, User> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void delete(final User entity) {
|
public void delete(final User entity) {
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ public class ApplicationManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public <T extends CcmApplication> T createInstance(
|
public <T extends CcmApplication> T createInstance(
|
||||||
final ApplicationType type,
|
final ApplicationType type,
|
||||||
|
|
@ -103,7 +103,7 @@ public class ApplicationManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void deleteInstance(final CcmApplication application) {
|
public void deleteInstance(final CcmApplication application) {
|
||||||
entityManager.remove(application);
|
entityManager.remove(application);
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ public class ApplicationRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void save(final CcmApplication application) {
|
public void save(final CcmApplication application) {
|
||||||
|
|
@ -96,7 +96,7 @@ public class ApplicationRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void delete(final CcmApplication application) {
|
public void delete(final CcmApplication application) {
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ public class WorkflowManager {
|
||||||
private Shiro shiro;
|
private Shiro shiro;
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public Workflow createWorkflow(final WorkflowTemplate template) {
|
public Workflow createWorkflow(final WorkflowTemplate template) {
|
||||||
final Workflow workflow = new Workflow();
|
final Workflow workflow = new Workflow();
|
||||||
|
|
@ -169,7 +169,7 @@ public class WorkflowManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void addTask(final Workflow workflow, final Task task) {
|
public void addTask(final Workflow workflow, final Task task) {
|
||||||
workflow.addTask(task);
|
workflow.addTask(task);
|
||||||
|
|
@ -180,7 +180,7 @@ public class WorkflowManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void removeTask(final Workflow workflow, final Task task) {
|
public void removeTask(final Workflow workflow, final Task task) {
|
||||||
workflow.removeTask(task);
|
workflow.removeTask(task);
|
||||||
|
|
@ -191,7 +191,7 @@ public class WorkflowManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void assignTask(final UserTask task, final Role role) {
|
public void assignTask(final UserTask task, final Role role) {
|
||||||
final TaskAssignment assignment = new TaskAssignment();
|
final TaskAssignment assignment = new TaskAssignment();
|
||||||
|
|
@ -207,7 +207,7 @@ public class WorkflowManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void retractTask(final UserTask task, final Role role) {
|
public void retractTask(final UserTask task, final Role role) {
|
||||||
final List<TaskAssignment> result = task.getAssignments().stream()
|
final List<TaskAssignment> result = task.getAssignments().stream()
|
||||||
|
|
@ -223,7 +223,7 @@ public class WorkflowManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void addDependentTask(final Task parent, final Task task) {
|
public void addDependentTask(final Task parent, final Task task) {
|
||||||
parent.addDependentTask(task);
|
parent.addDependentTask(task);
|
||||||
|
|
@ -234,7 +234,7 @@ public class WorkflowManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void removeDependentTask(final Task parent, final Task task) {
|
public void removeDependentTask(final Task parent, final Task task) {
|
||||||
parent.removeDependentTask(task);
|
parent.removeDependentTask(task);
|
||||||
|
|
@ -245,7 +245,7 @@ public class WorkflowManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void lockTask(final UserTask task) {
|
public void lockTask(final UserTask task) {
|
||||||
task.setLocked(true);
|
task.setLocked(true);
|
||||||
|
|
@ -255,7 +255,7 @@ public class WorkflowManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void unlockTask(final UserTask task) {
|
public void unlockTask(final UserTask task) {
|
||||||
task.setLocked(false);
|
task.setLocked(false);
|
||||||
|
|
@ -265,7 +265,7 @@ public class WorkflowManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public List<UserTask> lockedBy(final User user) {
|
public List<UserTask> lockedBy(final User user) {
|
||||||
final TypedQuery<UserTask> query = entityManager.createNamedQuery(
|
final TypedQuery<UserTask> query = entityManager.createNamedQuery(
|
||||||
|
|
|
||||||
|
|
@ -42,14 +42,19 @@ import org.libreccm.core.CcmObject;
|
||||||
import org.libreccm.core.CcmObjectRepository;
|
import org.libreccm.core.CcmObjectRepository;
|
||||||
import org.libreccm.tests.categories.IntegrationTest;
|
import org.libreccm.tests.categories.IntegrationTest;
|
||||||
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
|
import org.libreccm.categorization.CategorizationConstants;
|
||||||
|
import org.libreccm.core.CoreConstants;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
|
@ -501,8 +506,7 @@ public class PermissionManagerTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected
|
@Test(expected = IllegalArgumentException.class)
|
||||||
= IllegalArgumentException.class)
|
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
|
|
@ -518,4 +522,34 @@ public class PermissionManagerTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies if
|
||||||
|
* {@link PermissionManager#listDefiniedPrivileges(java.lang.Class)} returns
|
||||||
|
* the expected value.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
@InSequence(500)
|
||||||
|
public void verifyListPrivileges() {
|
||||||
|
|
||||||
|
final List<String> corePrivileges = permissionManager
|
||||||
|
.listDefiniedPrivileges(CoreConstants.class);
|
||||||
|
final List<String> catPrivileges = permissionManager
|
||||||
|
.listDefiniedPrivileges(CategorizationConstants.class);
|
||||||
|
|
||||||
|
assertThat(corePrivileges, is(not(nullValue())));
|
||||||
|
assertThat(corePrivileges.isEmpty(), is(false));
|
||||||
|
assertThat(corePrivileges.size(), is(2));
|
||||||
|
assertThat(corePrivileges, contains(CoreConstants.PRIVILEGE_ADMIN,
|
||||||
|
CoreConstants.PRIVILEGE_SYSTEM));
|
||||||
|
|
||||||
|
assertThat(catPrivileges, is(not(nullValue())));
|
||||||
|
assertThat(catPrivileges.isEmpty(), is(false));
|
||||||
|
assertThat(catPrivileges.size(), is(3));
|
||||||
|
assertThat(catPrivileges,
|
||||||
|
contains(CategorizationConstants.PRIVILEGE_MANAGE_CATEGORY,
|
||||||
|
CategorizationConstants.PRIVILEGE_MANAGE_CATEGORY_OBJECTS,
|
||||||
|
CategorizationConstants.PRIVILEGE_MANAGE_DOMAINS));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue