| .. | .. |
|---|
| 38 | 38 | import net.curisit.securis.db.PackMetadata; |
|---|
| 39 | 39 | import net.curisit.securis.db.PackStatus; |
|---|
| 40 | 40 | import net.curisit.securis.db.User; |
|---|
| 41 | +import net.curisit.securis.db.User.Rol; |
|---|
| 41 | 42 | import net.curisit.securis.ioc.EnsureTransaction; |
|---|
| 42 | 43 | import net.curisit.securis.security.BasicSecurityContext; |
|---|
| 43 | 44 | import net.curisit.securis.security.Securable; |
|---|
| .. | .. |
|---|
| 90 | 91 | LOG.info("Getting all packs for user: " + bsc.getUserPrincipal()); |
|---|
| 91 | 92 | q = em.createNamedQuery("list-packs", Pack.class); |
|---|
| 92 | 93 | } else { |
|---|
| 93 | | - if (bsc.getOrganizationsIds() == null || bsc.getOrganizationsIds().isEmpty() || // |
|---|
| 94 | | - bsc.getApplicationsIds() == null || bsc.getApplicationsIds().isEmpty()) { |
|---|
| 94 | + if (bsc.getApplicationsIds() == null || bsc.getApplicationsIds().isEmpty()) { |
|---|
| 95 | 95 | return Response.ok().build(); |
|---|
| 96 | 96 | } |
|---|
| 97 | | - q = em.createNamedQuery("list-packs-by-orgs-apps", Pack.class); |
|---|
| 98 | | - q.setParameter("list_ids_org", bsc.getOrganizationsIds()); |
|---|
| 97 | + if (bsc.getOrganizationsIds() == null || bsc.getOrganizationsIds().isEmpty()) { |
|---|
| 98 | + q = em.createNamedQuery("list-packs-by-apps", Pack.class); |
|---|
| 99 | + } else { |
|---|
| 100 | + q = em.createNamedQuery("list-packs-by-orgs-apps", Pack.class); |
|---|
| 101 | + q.setParameter("list_ids_org", bsc.getOrganizationsIds()); |
|---|
| 102 | + } |
|---|
| 99 | 103 | q.setParameter("list_ids_app", bsc.getApplicationsIds()); |
|---|
| 100 | 104 | LOG.info("Getting packs from orgs: {} and apps: {}", bsc.getOrganizationsIds(), bsc.getApplicationsIds()); |
|---|
| 101 | 105 | } |
|---|
| .. | .. |
|---|
| 140 | 144 | |
|---|
| 141 | 145 | @POST |
|---|
| 142 | 146 | @Path("/") |
|---|
| 143 | | - @Securable |
|---|
| 147 | + @Securable(roles = Rol.ADMIN | Rol.ADVANCE) |
|---|
| 144 | 148 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 145 | 149 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 146 | 150 | @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| .. | .. |
|---|
| 207 | 211 | */ |
|---|
| 208 | 212 | @GET |
|---|
| 209 | 213 | @Path("/{packId}/next_license_code") |
|---|
| 210 | | - @Securable |
|---|
| 214 | + @Securable(roles = Rol.ADMIN | Rol.ADVANCE) |
|---|
| 211 | 215 | @Produces({ MediaType.TEXT_PLAIN }) |
|---|
| 212 | 216 | public Response getCodeSuffix(@PathParam("packId") Integer packId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 213 | 217 | // EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 249 | 253 | @POST |
|---|
| 250 | 254 | @Path("/{packId}") |
|---|
| 251 | 255 | @EnsureTransaction |
|---|
| 252 | | - @Securable |
|---|
| 256 | + @Securable(roles = Rol.ADMIN | Rol.ADVANCE) |
|---|
| 253 | 257 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 254 | 258 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 255 | 259 | @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| .. | .. |
|---|
| 314 | 318 | @POST |
|---|
| 315 | 319 | @Path("/{packId}/activate") |
|---|
| 316 | 320 | @EnsureTransaction |
|---|
| 317 | | - @Securable |
|---|
| 321 | + @Securable(roles = Rol.ADMIN | Rol.ADVANCE) |
|---|
| 318 | 322 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 319 | 323 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 320 | 324 | @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| .. | .. |
|---|
| 338 | 342 | @POST |
|---|
| 339 | 343 | @Path("/{packId}/putonhold") |
|---|
| 340 | 344 | @EnsureTransaction |
|---|
| 341 | | - @Securable |
|---|
| 345 | + @Securable(roles = Rol.ADMIN | Rol.ADVANCE) |
|---|
| 342 | 346 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 343 | 347 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 344 | 348 | @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| .. | .. |
|---|
| 362 | 366 | @POST |
|---|
| 363 | 367 | @Path("/{packId}/cancel") |
|---|
| 364 | 368 | @EnsureTransaction |
|---|
| 365 | | - @Securable |
|---|
| 369 | + @Securable(roles = Rol.ADMIN | Rol.ADVANCE) |
|---|
| 366 | 370 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 367 | 371 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 368 | 372 | @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| .. | .. |
|---|
| 403 | 407 | |
|---|
| 404 | 408 | @DELETE |
|---|
| 405 | 409 | @Path("/{packId}") |
|---|
| 406 | | - @Securable |
|---|
| 410 | + @Securable(roles = Rol.ADMIN | Rol.ADVANCE) |
|---|
| 407 | 411 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 408 | 412 | @EnsureTransaction |
|---|
| 409 | 413 | @Produces({ MediaType.APPLICATION_JSON }) |
|---|