Skip to content

Commit

Permalink
a_roles_read action is now used
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-stastny committed Oct 15, 2024
1 parent 4bd90eb commit f78b2b5
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public class RolesResource {
@Produces(MediaType.APPLICATION_JSON+ ";charset=utf-8")
public Response role(@PathParam("id") String roleId) {
try {
if (permit(this.userProvider.get())) {
User user = this.userProvider.get();
if (permitRead(user) || permit(user)) {
//if (permit(this.userProvider.get())) {
Role role = this.userManager.findRole(Integer.parseInt(roleId));
if (role != null) {
return Response.ok().entity(roleToJSON(role).toString()).build();
Expand Down Expand Up @@ -136,8 +138,8 @@ public Response getRoles(
@QueryParam("resultSize") String filterResultSize,
@QueryParam("ordering") String filterOrdering,
@QueryParam("typefordering") @DefaultValue("ASC")String typeofordering) {

if (permit(this.userProvider.get())) {
User user = this.userProvider.get();
if (permitRead(user) || permit(user)) {
try {
Offset offset = null;
if (StringUtils.isAnyString(filterOffset) || StringUtils.isAnyString(filterResultSize)) {
Expand Down Expand Up @@ -249,6 +251,15 @@ public static Role createRoleFromJSON(int id, JSONObject uOptions) throws JSONEx
return r;
}

boolean permitRead(User user) {
if (user != null) {
boolean retval = this.rightsResolver.isActionAllowed(user,SecuredActions.A_ROLES_READ.getFormalName(), SpecialObjects.REPOSITORY.getPid(), null , ObjectPidsPath.REPOSITORY_PATH).flag();
return retval;
} else {
return false;
}
}

boolean permit(User user) {
if (user != null) {
boolean retval = this.rightsResolver.isActionAllowed(user,SecuredActions.A_ROLES_EDIT.getFormalName(), SpecialObjects.REPOSITORY.getPid(), null , ObjectPidsPath.REPOSITORY_PATH).flag();
Expand Down

0 comments on commit f78b2b5

Please sign in to comment.