@Test public void testDeletePrivilege() { Privilege priv = createPrivilege("wildcard", "priv", "privdesc", false, PATTERN_KEY, "a:pattern"); when(authorizationManager.getPrivilege("priv")).thenReturn(priv); underTest.deletePrivilege("priv"); verify(authorizationManager).deletePrivilege("priv"); }
@Override @DELETE @RequiresAuthentication @RequiresPermissions("nexus:privileges:delete") @Path("{privilegeId}") public void deletePrivilege(@PathParam("privilegeId") final String privilegeId) { try { getDefaultAuthorizationManager().deletePrivilege(privilegeId); } catch (NoSuchPrivilegeException e) { log.debug("Attempt to delete privilege '{}' failed, as it wasn't found in the system.", privilegeId, e); throw new WebApplicationMessageException(Status.NOT_FOUND, String.format(PRIV_NOT_FOUND, privilegeId), MediaType.APPLICATION_JSON); } catch (ReadonlyPrivilegeException e) { log.debug("Attempt to delete privilege '{}' failed, as it is readonly.", privilegeId, e); throw new WebApplicationMessageException(Status.BAD_REQUEST, String.format(PRIV_INTERNAL, privilegeId), MediaType.APPLICATION_JSON); } }
PrivilegeApiResource extends PrivilegeApiResourceSupport implements Resource, PrivilegeApiResourceDoc { @Override @DELETE @RequiresAuthentication @RequiresPermissions("nexus:privileges:delete") @Path("{privilegeId}") public void deletePrivilege(@PathParam("privilegeId") final String privilegeId) { try { getDefaultAuthorizationManager().deletePrivilege(privilegeId); } catch (NoSuchPrivilegeException e) { log.debug("Attempt to delete privilege '{}' failed, as it wasn't found in the system.", privilegeId, e); throw new WebApplicationMessageException(Status.NOT_FOUND, String.format(PRIV_NOT_FOUND, privilegeId), MediaType.APPLICATION_JSON); } catch (ReadonlyPrivilegeException e) { log.debug("Attempt to delete privilege '{}' failed, as it is readonly.", privilegeId, e); throw new WebApplicationMessageException(Status.BAD_REQUEST, String.format(PRIV_INTERNAL, privilegeId), MediaType.APPLICATION_JSON); } } }
PrivilegeApiResource extends PrivilegeApiResourceSupport implements Resource, PrivilegeApiResourceDoc { @Override @DELETE @RequiresAuthentication @RequiresPermissions("nexus:privileges:delete") @Path("{privilegeId}") public void deletePrivilege(@PathParam("privilegeId") final String privilegeId) { try { getDefaultAuthorizationManager().deletePrivilege(privilegeId); } catch (NoSuchPrivilegeException e) { log.debug("Attempt to delete privilege '{}' failed, as it wasn't found in the system.", privilegeId, e); throw new WebApplicationMessageException(Status.NOT_FOUND, String.format(PRIV_NOT_FOUND, privilegeId), MediaType.APPLICATION_JSON); } catch (ReadonlyPrivilegeException e) { log.debug("Attempt to delete privilege '{}' failed, as it is readonly.", privilegeId, e); throw new WebApplicationMessageException(Status.BAD_REQUEST, String.format(PRIV_INTERNAL, privilegeId), MediaType.APPLICATION_JSON); } } @Inject  PrivilegeApiResource(final SecuritySystem securitySystem,
                              final Map<String, PrivilegeDescriptor> privilegeDescriptors); }
PrivilegeApiResource extends PrivilegeApiResourceSupport implements Resource, PrivilegeApiResourceDoc { @Override @DELETE @RequiresAuthentication @RequiresPermissions("nexus:privileges:delete") @Path("{privilegeId}") public void deletePrivilege(@PathParam("privilegeId") final String privilegeId) { try { getDefaultAuthorizationManager().deletePrivilege(privilegeId); } catch (NoSuchPrivilegeException e) { log.debug("Attempt to delete privilege '{}' failed, as it wasn't found in the system.", privilegeId, e); throw new WebApplicationMessageException(Status.NOT_FOUND, String.format(PRIV_NOT_FOUND, privilegeId), MediaType.APPLICATION_JSON); } catch (ReadonlyPrivilegeException e) { log.debug("Attempt to delete privilege '{}' failed, as it is readonly.", privilegeId, e); throw new WebApplicationMessageException(Status.BAD_REQUEST, String.format(PRIV_INTERNAL, privilegeId), MediaType.APPLICATION_JSON); } } @Inject  PrivilegeApiResource(final SecuritySystem securitySystem,
                              final Map<String, PrivilegeDescriptor> privilegeDescriptors); @Override @GET @RequiresAuthentication @RequiresPermissions("nexus:privileges:read") List<ApiPrivilege> getPrivileges(); @Override @GET @RequiresAuthentication @RequiresPermissions("nexus:privileges:read") @Path("{privilegeId}") ApiPrivilege getPrivilege(@PathParam("privilegeId") final String privilegeId); @Override @DELETE @RequiresAuthentication @RequiresPermissions("nexus:privileges:delete") @Path("{privilegeId}") void deletePrivilege(@PathParam("privilegeId") final String privilegeId); @Override @POST @RequiresAuthentication @RequiresPermissions("nexus:privileges:create") @Path("application") Response createPrivilege(final ApiPrivilegeApplicationRequest privilege); @Override @PUT @RequiresAuthentication @RequiresPermissions("nexus:privileges:update") @Path("application/{privilegeId}") void updatePrivilege(@PathParam("privilegeId") final String privilegeId,
                              final ApiPrivilegeApplicationRequest privilege); @Override @POST @RequiresAuthentication @RequiresPermissions("nexus:privileges:create") @Path("wildcard") Response createPrivilege(final ApiPrivilegeWildcardRequest privilege); @Override @PUT @RequiresAuthentication @RequiresPermissions("nexus:privileges:update") @Path("wildcard/{privilegeId}") void updatePrivilege(@PathParam("privilegeId") final String privilegeId,
                              final ApiPrivilegeWildcardRequest privilege); }
PrivilegeApiResource extends PrivilegeApiResourceSupport implements Resource, PrivilegeApiResourceDoc { @Override @DELETE @RequiresAuthentication @RequiresPermissions("nexus:privileges:delete") @Path("{privilegeId}") public void deletePrivilege(@PathParam("privilegeId") final String privilegeId) { try { getDefaultAuthorizationManager().deletePrivilege(privilegeId); } catch (NoSuchPrivilegeException e) { log.debug("Attempt to delete privilege '{}' failed, as it wasn't found in the system.", privilegeId, e); throw new WebApplicationMessageException(Status.NOT_FOUND, String.format(PRIV_NOT_FOUND, privilegeId), MediaType.APPLICATION_JSON); } catch (ReadonlyPrivilegeException e) { log.debug("Attempt to delete privilege '{}' failed, as it is readonly.", privilegeId, e); throw new WebApplicationMessageException(Status.BAD_REQUEST, String.format(PRIV_INTERNAL, privilegeId), MediaType.APPLICATION_JSON); } } @Inject  PrivilegeApiResource(final SecuritySystem securitySystem,
                              final Map<String, PrivilegeDescriptor> privilegeDescriptors); @Override @GET @RequiresAuthentication @RequiresPermissions("nexus:privileges:read") List<ApiPrivilege> getPrivileges(); @Override @GET @RequiresAuthentication @RequiresPermissions("nexus:privileges:read") @Path("{privilegeId}") ApiPrivilege getPrivilege(@PathParam("privilegeId") final String privilegeId); @Override @DELETE @RequiresAuthentication @RequiresPermissions("nexus:privileges:delete") @Path("{privilegeId}") void deletePrivilege(@PathParam("privilegeId") final String privilegeId); @Override @POST @RequiresAuthentication @RequiresPermissions("nexus:privileges:create") @Path("application") Response createPrivilege(final ApiPrivilegeApplicationRequest privilege); @Override @PUT @RequiresAuthentication @RequiresPermissions("nexus:privileges:update") @Path("application/{privilegeId}") void updatePrivilege(@PathParam("privilegeId") final String privilegeId,
                              final ApiPrivilegeApplicationRequest privilege); @Override @POST @RequiresAuthentication @RequiresPermissions("nexus:privileges:create") @Path("wildcard") Response createPrivilege(final ApiPrivilegeWildcardRequest privilege); @Override @PUT @RequiresAuthentication @RequiresPermissions("nexus:privileges:update") @Path("wildcard/{privilegeId}") void updatePrivilege(@PathParam("privilegeId") final String privilegeId,
                              final ApiPrivilegeWildcardRequest privilege);  }