| .. | .. |
|---|
| 5 | 5 | import java.util.List; |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | import javax.annotation.security.RolesAllowed; |
|---|
| 8 | | -import javax.crypto.SealedObject; |
|---|
| 9 | 8 | import javax.inject.Inject; |
|---|
| 10 | 9 | import javax.inject.Provider; |
|---|
| 11 | 10 | import javax.persistence.EntityManager; |
|---|
| .. | .. |
|---|
| 34 | 33 | import net.curisit.securis.security.Securable; |
|---|
| 35 | 34 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 36 | 35 | |
|---|
| 37 | | -import org.apache.logging.log4j.Logger; |
|---|
| 38 | 36 | import org.apache.logging.log4j.LogManager; |
|---|
| 37 | +import org.apache.logging.log4j.Logger; |
|---|
| 39 | 38 | |
|---|
| 40 | 39 | import com.google.inject.persist.Transactional; |
|---|
| 41 | 40 | |
|---|
| .. | .. |
|---|
| 56 | 55 | @Inject |
|---|
| 57 | 56 | Provider<EntityManager> emProvider; |
|---|
| 58 | 57 | |
|---|
| 59 | | - public PackResource() {} |
|---|
| 58 | + public PackResource() { |
|---|
| 59 | + } |
|---|
| 60 | 60 | |
|---|
| 61 | 61 | /** |
|---|
| 62 | 62 | * |
|---|
| .. | .. |
|---|
| 65 | 65 | @GET |
|---|
| 66 | 66 | @Path("/") |
|---|
| 67 | 67 | @Securable |
|---|
| 68 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 68 | + @Produces({ |
|---|
| 69 | + MediaType.APPLICATION_JSON |
|---|
| 70 | + }) |
|---|
| 69 | 71 | public Response index(@Context BasicSecurityContext bsc) { |
|---|
| 70 | 72 | LOG.info("Getting packs list "); |
|---|
| 71 | 73 | |
|---|
| .. | .. |
|---|
| 100 | 102 | @GET |
|---|
| 101 | 103 | @Path("/{packId}") |
|---|
| 102 | 104 | @Securable |
|---|
| 103 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 105 | + @Produces({ |
|---|
| 106 | + MediaType.APPLICATION_JSON |
|---|
| 107 | + }) |
|---|
| 104 | 108 | public Response get(@PathParam("packId") Integer packId, @Context BasicSecurityContext bsc) { |
|---|
| 105 | 109 | LOG.info("Getting pack data for id: {}: ", packId); |
|---|
| 106 | 110 | if (packId == null || "".equals(packId)) { |
|---|
| .. | .. |
|---|
| 114 | 118 | LOG.error("Pack with id {} not found in DB", packId); |
|---|
| 115 | 119 | return Response.status(Status.NOT_FOUND).build(); |
|---|
| 116 | 120 | } |
|---|
| 117 | | - if (bsc.isUserInRole(BasicSecurityContext.ROL_ADVANCE)) { |
|---|
| 118 | | - if (bsc.getOrganizationsIds() == null || !bsc.getOrganizationsIds().contains(pack.getOrgId())) { |
|---|
| 119 | | - return generateErrorUnathorizedAccess(pack, bsc.getUserPrincipal()); |
|---|
| 120 | | - } |
|---|
| 121 | + if (bsc.isUserInRole(BasicSecurityContext.ROL_ADVANCE) |
|---|
| 122 | + && (bsc.getOrganizationsIds() == null || !bsc.getOrganizationsIds().contains(pack.getOrgId()))) { |
|---|
| 123 | + return generateErrorUnathorizedAccess(pack, bsc.getUserPrincipal()); |
|---|
| 121 | 124 | } |
|---|
| 122 | 125 | return Response.ok(pack).build(); |
|---|
| 123 | 126 | } |
|---|
| .. | .. |
|---|
| 127 | 130 | @Securable |
|---|
| 128 | 131 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 129 | 132 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 130 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 133 | + @Produces({ |
|---|
| 134 | + MediaType.APPLICATION_JSON |
|---|
| 135 | + }) |
|---|
| 131 | 136 | @Transactional |
|---|
| 132 | 137 | public Response create(Pack pack, @Context BasicSecurityContext bsc) { |
|---|
| 133 | 138 | LOG.info("Creating new pack"); |
|---|
| .. | .. |
|---|
| 173 | 178 | @Securable |
|---|
| 174 | 179 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 175 | 180 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 176 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 181 | + @Produces({ |
|---|
| 182 | + MediaType.APPLICATION_JSON |
|---|
| 183 | + }) |
|---|
| 177 | 184 | public Response modify(Pack pack, @PathParam("packId") Integer packId) { |
|---|
| 178 | 185 | LOG.info("Modifying pack with id: {}", packId); |
|---|
| 179 | 186 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 218 | 225 | @Securable |
|---|
| 219 | 226 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 220 | 227 | @Transactional |
|---|
| 221 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 228 | + @Produces({ |
|---|
| 229 | + MediaType.APPLICATION_JSON |
|---|
| 230 | + }) |
|---|
| 222 | 231 | public Response delete(@PathParam("packId") String packId) { |
|---|
| 223 | 232 | LOG.info("Deleting pack with id: {}", packId); |
|---|
| 224 | 233 | EntityManager em = emProvider.get(); |
|---|