String loggedInUser = CarbonContext.getCurrentContext().getUsername();
if (!userRealm.getAuthorizationManager().isUserAuthorized(
loggedInUser, queueResourcePath,
MessageBoxConstants.MB_PERMISSION_CHANGE_PERMISSION)) {
if (!Utils.isAdmin(loggedInUser)) {
throw new MessageBoxException(" User " + loggedInUser + " can not change" +
" the permissions of " + queueName);
}
}
for (QueueRolePermission queueRolePermission : queueRolePermissions) {
role = queueRolePermission.getRoleName();
if (queueRolePermission.isAllowedToConsume()) {
if (!userRealm.getAuthorizationManager().isRoleAuthorized(
role, queueResourcePath, MessageBoxConstants.MB_PERMISSION_CONSUME)) {
userRealm.getAuthorizationManager().authorizeRole(
role, queueResourcePath, MessageBoxConstants.MB_PERMISSION_CONSUME);
}
} else {
if (userRealm.getAuthorizationManager().isRoleAuthorized(
role, queueResourcePath, MessageBoxConstants.MB_PERMISSION_CONSUME)) {
userRealm.getAuthorizationManager().denyRole(
role, queueResourcePath, MessageBoxConstants.MB_PERMISSION_CONSUME);
}
}
if (queueRolePermission.isAllowedToPublish()) {
if (!userRealm.getAuthorizationManager().isRoleAuthorized(
role, queueResourcePath, MessageBoxConstants.MB_PERMISSION_PUBLISH)) {
userRealm.getAuthorizationManager().authorizeRole(
role, queueResourcePath, MessageBoxConstants.MB_PERMISSION_PUBLISH);
}
} else {
if (userRealm.getAuthorizationManager().isRoleAuthorized(
role, queueResourcePath, MessageBoxConstants.MB_PERMISSION_PUBLISH)) {
userRealm.getAuthorizationManager().denyRole(
role, queueResourcePath, MessageBoxConstants.MB_PERMISSION_PUBLISH);
}
}
}
setQueueUpdatedTime(queueName);
} catch (UserStoreException e) {
throw new MessageBoxException("Can not access the user store manager", e);
}
}