public static void changeRolePermissions(UserRegistry userRegistry,
String resourcePath, String permissionString)
throws Exception {
AuthorizationManager accessControlAdmin ;
UserRealm realm;
try {
realm = userRegistry.getUserRealm();
accessControlAdmin = realm.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[] rolePermissions = permissionString.split("\\|");
for (int i = 0; i < rolePermissions.length; i++) {
String notificationResponse = "The following changes have been made.";
if (rolePermissions[i].trim().length() == 0) {
continue;
}
String[] permissions = rolePermissions[i].split(":");
String permRole = permissions[0];
RealmConfiguration realmConfig = realm.getRealmConfiguration();
if (!permRole.equals(realmConfig.getAdminRoleName())) {
accessControlAdmin.clearRoleAuthorization(permRole, resourcePath, ActionConstants.GET);
accessControlAdmin.clearRoleAuthorization(permRole, resourcePath, ActionConstants.PUT);
accessControlAdmin.clearRoleAuthorization(permRole, resourcePath, ActionConstants.DELETE);
accessControlAdmin.clearRoleAuthorization(permRole, resourcePath, AccessControlConstants.AUTHORIZE);