String pathToAuthorize,
String roleToAuthorize,
String actionToAuthorize,
String permissionType) throws Exception {
UserRealm userRealm ;
try {
userRealm = userRegistry.getUserRealm();
userRealm.getAuthorizationManager();
} catch (Exception e) {
String msg =
"Couldn't get access control admin for changing authorizations. Caused by: " +
e.getMessage();
log.error(msg, e);
throw new RegistryException(msg, e);
}
try {
String notificationResponse = "The following authorization has been added.";
if (actionToAuthorize.equals("2")) {
if (permissionType.equals("1")) {
userRealm.getAuthorizationManager().authorizeRole(roleToAuthorize, pathToAuthorize, ActionConstants.GET);
notificationResponse += " READ: Allowed.";
} else {
userRealm.getAuthorizationManager().denyRole(roleToAuthorize, pathToAuthorize, ActionConstants.GET);
notificationResponse += " READ: Denied.";
}
}
if (actionToAuthorize.equals("3")) {
if (permissionType.equals("1")) {
userRealm.getAuthorizationManager().authorizeRole(roleToAuthorize, pathToAuthorize, ActionConstants.PUT);
notificationResponse += " WRITE: Allowed.";
} else {
userRealm.getAuthorizationManager().denyRole(roleToAuthorize, pathToAuthorize, ActionConstants.PUT);
notificationResponse += " WRITE: Denied.";
}
}
if (actionToAuthorize.equals("4")) {
if (permissionType.equals("1")) {
userRealm.getAuthorizationManager().authorizeRole(roleToAuthorize, pathToAuthorize, ActionConstants.DELETE);
notificationResponse += " DELETE: Allowed.";
} else {
userRealm.getAuthorizationManager().denyRole(roleToAuthorize, pathToAuthorize, ActionConstants.DELETE);
notificationResponse += " DELETE: Denied.";
}
}
if (actionToAuthorize.equals("5")) {
if (permissionType.equals("1")) {
userRealm.getAuthorizationManager().authorizeRole(roleToAuthorize, pathToAuthorize, AccessControlConstants.AUTHORIZE);
notificationResponse += " AUTHORIZE: Allowed.";
} else {
userRealm.getAuthorizationManager().denyRole(roleToAuthorize, pathToAuthorize, AccessControlConstants.AUTHORIZE);
notificationResponse += " AUTHORIZE: Denied.";
}
}
String message = "Permissions have been added for the role " + roleToAuthorize + " on resource " +