Roberto Sánchez
2014-09-19 071a008cf28e733ca3aaafa57e675fd54a5ea33b
#396 fix - Fixed more SonarQube issues, new code style applied
27 files modified
changed files
securis/src/main/java/net/curisit/securis/AuthFilter.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/MainApp.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/RestServicesApplication.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/dao/UserDao.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/Application.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/License.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/LicenseHistory.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/LicenseType.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/Organization.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/Pack.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/User.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/security/Securable.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/security/SecurityInterceptor.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/ApiResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/ApplicationResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/BasicServices.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/LicenseResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/LicenseServices.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/LicenseTypeResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/OrganizationResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/PackResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/UserResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/utils/CacheTTL.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/utils/TokenHelper.java patch | view | blame | history
securis/src/patch/java/net/curisit/securis/LicenseGenerator.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/AuthFilter.java
....@@ -14,9 +14,8 @@
1414 import javax.servlet.http.HttpServletRequest;
1515 import javax.servlet.http.HttpServletRequestWrapper;
1616
17
-import org.apache.logging.log4j.Logger;
18
-
1917 import org.apache.logging.log4j.LogManager;
18
+import org.apache.logging.log4j.Logger;
2019
2120 @Singleton
2221 @WebFilter(urlPatterns = "/*")
....@@ -25,7 +24,8 @@
2524 private static final Logger LOG = LogManager.getLogger(AuthFilter.class);
2625
2726 @Override
28
- public void init(FilterConfig fc) throws ServletException {}
27
+ public void init(FilterConfig fc) throws ServletException {
28
+ }
2929
3030 @Override
3131 public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) throws IOException, ServletException {
....@@ -47,7 +47,8 @@
4747 }
4848
4949 @Override
50
- public void destroy() {}
50
+ public void destroy() {
51
+ }
5152
5253 private class UserRoleRequestWrapper extends HttpServletRequestWrapper {
5354
....@@ -83,4 +84,4 @@
8384 };
8485 }
8586 }
86
-}
87
+}
securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java
....@@ -12,8 +12,8 @@
1212
1313 import net.curisit.securis.services.exception.SeCurisServiceException;
1414
15
-import org.apache.logging.log4j.Logger;
1615 import org.apache.logging.log4j.LogManager;
16
+import org.apache.logging.log4j.Logger;
1717
1818 @Provider
1919 public class DefaultExceptionHandler implements ExceptionMapper<Exception> {
....@@ -49,4 +49,4 @@
4949 LOG.error("Request url: " + request.getRequestURL(), e);
5050 return Response.serverError().header(ERROR_MESSAGE_HEADER, "Unexpected error: " + e.toString()).type(MediaType.APPLICATION_JSON).build();
5151 }
52
-}
52
+}
securis/src/main/java/net/curisit/securis/MainApp.java
....@@ -9,6 +9,8 @@
99 import net.curisit.securis.ioc.RequestsModule;
1010 import net.curisit.securis.ioc.SecurisModule;
1111
12
+import org.apache.logging.log4j.LogManager;
13
+import org.apache.logging.log4j.Logger;
1214 import org.eclipse.jetty.server.Handler;
1315 import org.eclipse.jetty.server.Server;
1416 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
....@@ -20,8 +22,6 @@
2022 import org.eclipse.jetty.util.resource.Resource;
2123 import org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener;
2224 import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher;
23
-import org.apache.logging.log4j.Logger;
24
-import org.apache.logging.log4j.LogManager;
2525
2626 import com.google.inject.Guice;
2727 import com.google.inject.Injector;
....@@ -77,7 +77,9 @@
7777
7878 ResourceHandler staticResources = new ResourceHandler();
7979 staticResources.setBaseResource(Resource.newResource(MainApp.class.getResource("/static").toURI()));
80
- staticResources.setWelcomeFiles(new String[] { "/main.html" });
80
+ staticResources.setWelcomeFiles(new String[] {
81
+ "/main.html"
82
+ });
8183 context.setHandler(staticResources);
8284
8385 ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
....@@ -85,7 +87,9 @@
8587 LOG.info("Error Handlers: " + context.getErrorHandler());
8688 ContextHandlerCollection contexts = new ContextHandlerCollection();
8789
88
- contexts.setHandlers(new Handler[] { staticResources, context });
90
+ contexts.setHandlers(new Handler[] {
91
+ staticResources, context
92
+ });
8993
9094 server.setHandler(context);
9195 server.start();
securis/src/main/java/net/curisit/securis/RestServicesApplication.java
....@@ -8,8 +8,8 @@
88 import net.curisit.securis.services.BasicServices;
99 import net.curisit.securis.services.LicenseServices;
1010
11
-import org.apache.logging.log4j.Logger;
1211 import org.apache.logging.log4j.LogManager;
12
+import org.apache.logging.log4j.Logger;
1313
1414 public class RestServicesApplication extends Application {
1515
securis/src/main/java/net/curisit/securis/dao/UserDao.java
....@@ -15,7 +15,8 @@
1515 public class UserDao {
1616
1717 @Inject
18
- public UserDao() {}
18
+ public UserDao() {
19
+ }
1920
2021 @Inject
2122 Provider<EntityManager> emProvider;
securis/src/main/java/net/curisit/securis/db/Application.java
....@@ -26,7 +26,9 @@
2626 @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
2727 @Entity
2828 @Table(name = "application")
29
-@NamedQueries({ @NamedQuery(name = "list-applications", query = "SELECT a FROM Application a") })
29
+@NamedQueries({
30
+ @NamedQuery(name = "list-applications", query = "SELECT a FROM Application a")
31
+})
3032 public class Application implements Serializable {
3133
3234 private static final long serialVersionUID = 1L;
securis/src/main/java/net/curisit/securis/db/License.java
....@@ -35,7 +35,9 @@
3535 @Entity
3636 @Table(name = "license")
3737 @JsonIgnoreProperties(ignoreUnknown = true)
38
-@NamedQueries({ @NamedQuery(name = "list-licenses-by-pack", query = "SELECT l FROM License l where l.pack.id = :packId") })
38
+@NamedQueries({
39
+ @NamedQuery(name = "list-licenses-by-pack", query = "SELECT l FROM License l where l.pack.id = :packId")
40
+})
3941 public class License implements Serializable {
4042
4143 private static final long serialVersionUID = 1L;
securis/src/main/java/net/curisit/securis/db/LicenseHistory.java
....@@ -27,7 +27,9 @@
2727 @Entity
2828 @Table(name = "license_history")
2929 @JsonIgnoreProperties(ignoreUnknown = true)
30
-@NamedQueries({ @NamedQuery(name = "list-license-history", query = "SELECT lh FROM LicenseHistory lh where lh.license.id = :licId") })
30
+@NamedQueries({
31
+ @NamedQuery(name = "list-license-history", query = "SELECT lh FROM LicenseHistory lh where lh.license.id = :licId")
32
+})
3133 public class LicenseHistory implements Serializable {
3234
3335 private static final long serialVersionUID = 1L;
securis/src/main/java/net/curisit/securis/db/LicenseType.java
....@@ -13,13 +13,13 @@
1313 import javax.persistence.NamedQuery;
1414 import javax.persistence.Table;
1515
16
+import org.apache.logging.log4j.LogManager;
17
+import org.apache.logging.log4j.Logger;
1618 import org.codehaus.jackson.annotate.JsonAutoDetect;
1719 import org.codehaus.jackson.annotate.JsonIgnore;
1820 import org.codehaus.jackson.annotate.JsonIgnoreProperties;
1921 import org.codehaus.jackson.annotate.JsonProperty;
2022 import org.codehaus.jackson.map.annotate.JsonSerialize;
21
-import org.apache.logging.log4j.Logger;
22
-import org.apache.logging.log4j.LogManager;
2323
2424 /**
2525 * Entity implementation class for Entity: license_type
....@@ -30,7 +30,9 @@
3030 @JsonIgnoreProperties(ignoreUnknown = true)
3131 @Entity
3232 @Table(name = "license_type")
33
-@NamedQueries({ @NamedQuery(name = "list-license_types", query = "SELECT lt FROM LicenseType lt") })
33
+@NamedQueries({
34
+ @NamedQuery(name = "list-license_types", query = "SELECT lt FROM LicenseType lt")
35
+})
3436 public class LicenseType implements Serializable {
3537
3638 private static final Logger LOG = LogManager.getLogger(LicenseType.class);
securis/src/main/java/net/curisit/securis/db/Organization.java
....@@ -21,12 +21,12 @@
2121 import javax.persistence.OneToMany;
2222 import javax.persistence.Table;
2323
24
+import org.apache.logging.log4j.LogManager;
25
+import org.apache.logging.log4j.Logger;
2426 import org.codehaus.jackson.annotate.JsonAutoDetect;
2527 import org.codehaus.jackson.annotate.JsonIgnore;
2628 import org.codehaus.jackson.annotate.JsonProperty;
2729 import org.codehaus.jackson.map.annotate.JsonSerialize;
28
-import org.apache.logging.log4j.Logger;
29
-import org.apache.logging.log4j.LogManager;
3030
3131 /**
3232 * Entity implementation class for Entity: organization
....@@ -36,9 +36,11 @@
3636 @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
3737 @Entity
3838 @Table(name = "organization")
39
-@NamedQueries({ @NamedQuery(name = "list-organizations", query = "SELECT o FROM Organization o"),
39
+@NamedQueries({
40
+ @NamedQuery(name = "list-organizations", query = "SELECT o FROM Organization o"),
4041 @NamedQuery(name = "list-organizations-by-ids", query = "SELECT o FROM Organization o where id in :list_ids"),
41
- @NamedQuery(name = "find-children-org", query = "SELECT o FROM Organization o where o.parentOrganization = :parentOrganization") })
42
+ @NamedQuery(name = "find-children-org", query = "SELECT o FROM Organization o where o.parentOrganization = :parentOrganization")
43
+})
4244 public class Organization implements Serializable {
4345
4446 @SuppressWarnings("unused")
....@@ -61,8 +63,12 @@
6163 // We don't include the users to limit the size of each row a the listing
6264 @ManyToMany(cascade = CascadeType.REMOVE)
6365 @JoinTable(name = "user_organization", //
64
- joinColumns = { @JoinColumn(name = "organization_id", referencedColumnName = "id") }, //
65
- inverseJoinColumns = { @JoinColumn(name = "username", referencedColumnName = "username") })
66
+ joinColumns = {
67
+ @JoinColumn(name = "organization_id", referencedColumnName = "id")
68
+ }, //
69
+ inverseJoinColumns = {
70
+ @JoinColumn(name = "username", referencedColumnName = "username")
71
+ })
6672 private List<User> users;
6773
6874 @JsonIgnore
securis/src/main/java/net/curisit/securis/db/Pack.java
....@@ -32,8 +32,10 @@
3232 @Entity
3333 @Table(name = "pack")
3434 @JsonIgnoreProperties(ignoreUnknown = true)
35
-@NamedQueries({ @NamedQuery(name = "list-packs", query = "SELECT pa FROM Pack pa"),//
36
- @NamedQuery(name = "list-packs-by-orgs", query = "SELECT pa FROM Pack pa where pa.organization.id in :list_ids") })
35
+@NamedQueries({
36
+ @NamedQuery(name = "list-packs", query = "SELECT pa FROM Pack pa"),//
37
+ @NamedQuery(name = "list-packs-by-orgs", query = "SELECT pa FROM Pack pa where pa.organization.id in :list_ids")
38
+})
3739 public class Pack implements Serializable {
3840
3941 private static final long serialVersionUID = 1L;
securis/src/main/java/net/curisit/securis/db/User.java
....@@ -30,10 +30,12 @@
3030 @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
3131 @Entity
3232 @Table(name = "user")
33
-@NamedQueries({ @NamedQuery(name = "list-users", query = "SELECT u FROM User u"),
33
+@NamedQueries({
34
+ @NamedQuery(name = "list-users", query = "SELECT u FROM User u"),
3435 @NamedQuery(name = "get-user", query = "SELECT u FROM User u where u.username = :username"),
3536 @NamedQuery(name = "auth-user", query = "SELECT u FROM User u where u.username = :username and u.password = :password"),
36
- @NamedQuery(name = "delete-all-users", query = "delete FROM User u") })
37
+ @NamedQuery(name = "delete-all-users", query = "delete FROM User u")
38
+})
3739 public class User implements Serializable {
3840
3941 private static final long serialVersionUID = 1L;
....@@ -67,8 +69,12 @@
6769 @JsonIgnore
6870 @ManyToMany
6971 @JoinTable(name = "user_organization", //
70
- joinColumns = { @JoinColumn(name = "username", referencedColumnName = "username") }, //
71
- inverseJoinColumns = { @JoinColumn(name = "organization_id", referencedColumnName = "id") } //
72
+ joinColumns = {
73
+ @JoinColumn(name = "username", referencedColumnName = "username")
74
+ }, //
75
+ inverseJoinColumns = {
76
+ @JoinColumn(name = "organization_id", referencedColumnName = "id")
77
+ } //
7278 )
7379 private Set<Organization> organizations;
7480
....@@ -214,7 +220,9 @@
214220 public static class Rol {
215221 public static final int ADVANCE = 0x01;
216222 public static final int ADMIN = 0x02;
217
- public static final int[] ALL = new int[] { ADVANCE, ADMIN };
223
+ public static final int[] ALL = new int[] {
224
+ ADVANCE, ADMIN
225
+ };
218226 }
219227
220228 }
securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java
....@@ -13,9 +13,9 @@
1313 import javax.ws.rs.core.UriBuilder;
1414 import javax.ws.rs.core.UriBuilderException;
1515
16
-import org.h2.jdbcx.JdbcDataSource;
17
-import org.apache.logging.log4j.Logger;
1816 import org.apache.logging.log4j.LogManager;
17
+import org.apache.logging.log4j.Logger;
18
+import org.h2.jdbcx.JdbcDataSource;
1919
2020 import com.google.inject.AbstractModule;
2121 import com.google.inject.Provides;
securis/src/main/java/net/curisit/securis/security/Securable.java
....@@ -19,4 +19,4 @@
1919 * Bit mask with the rol or roles necessary to access the method
2020 */
2121 int roles() default 0;
22
-}
22
+}
securis/src/main/java/net/curisit/securis/security/SecurityInterceptor.java
....@@ -21,14 +21,14 @@
2121 import net.curisit.securis.utils.CacheTTL;
2222 import net.curisit.securis.utils.TokenHelper;
2323
24
+import org.apache.logging.log4j.LogManager;
25
+import org.apache.logging.log4j.Logger;
2426 import org.jboss.resteasy.core.Dispatcher;
2527 import org.jboss.resteasy.core.ResourceMethodInvoker;
2628 import org.jboss.resteasy.core.ServerResponse;
2729 import org.jboss.resteasy.spi.Failure;
2830 import org.jboss.resteasy.spi.HttpRequest;
2931 import org.jboss.resteasy.spi.ResteasyProviderFactory;
30
-import org.apache.logging.log4j.Logger;
31
-import org.apache.logging.log4j.LogManager;
3232
3333 @Provider
3434 // @PreMatching
securis/src/main/java/net/curisit/securis/services/ApiResource.java
....@@ -11,8 +11,8 @@
1111
1212 import net.curisit.securis.utils.TokenHelper;
1313
14
-import org.apache.logging.log4j.Logger;
1514 import org.apache.logging.log4j.LogManager;
15
+import org.apache.logging.log4j.Logger;
1616
1717 /**
1818 * External API to be accessed by third parties
....@@ -31,7 +31,8 @@
3131 @Inject
3232 Provider<EntityManager> emProvider;
3333
34
- public ApiResource() {}
34
+ public ApiResource() {
35
+ }
3536
3637 /**
3738 *
....@@ -39,7 +40,9 @@
3940 */
4041 @GET
4142 @Path("/")
42
- @Produces({ MediaType.TEXT_PLAIN })
43
+ @Produces({
44
+ MediaType.TEXT_PLAIN
45
+ })
4346 public Response index() {
4447 return Response.ok("SeCuris API").build();
4548 }
securis/src/main/java/net/curisit/securis/services/ApplicationResource.java
....@@ -27,8 +27,8 @@
2727 import net.curisit.securis.db.Application;
2828 import net.curisit.securis.utils.TokenHelper;
2929
30
-import org.apache.logging.log4j.Logger;
3130 import org.apache.logging.log4j.LogManager;
31
+import org.apache.logging.log4j.Logger;
3232
3333 import com.google.inject.persist.Transactional;
3434
....@@ -49,7 +49,8 @@
4949
5050 private static final Logger LOG = LogManager.getLogger(ApplicationResource.class);
5151
52
- public ApplicationResource() {}
52
+ public ApplicationResource() {
53
+ }
5354
5455 /**
5556 *
....@@ -57,7 +58,9 @@
5758 */
5859 @GET
5960 @Path("/")
60
- @Produces({ MediaType.APPLICATION_JSON })
61
+ @Produces({
62
+ MediaType.APPLICATION_JSON
63
+ })
6164 public Response index() {
6265 LOG.info("Getting applications list ");
6366
....@@ -74,7 +77,9 @@
7477 */
7578 @GET
7679 @Path("/{appid}")
77
- @Produces({ MediaType.APPLICATION_JSON })
80
+ @Produces({
81
+ MediaType.APPLICATION_JSON
82
+ })
7883 public Response get(@PathParam("appid") String appid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
7984 LOG.info("Getting application data for id: {}: ", appid);
8085 if (appid == null || "".equals(appid)) {
....@@ -96,7 +101,9 @@
96101 @POST
97102 @Path("/")
98103 @Consumes(MediaType.APPLICATION_JSON)
99
- @Produces({ MediaType.APPLICATION_JSON })
104
+ @Produces({
105
+ MediaType.APPLICATION_JSON
106
+ })
100107 @Transactional
101108 public Response create(Application app, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
102109 LOG.info("Creating new application");
....@@ -112,7 +119,9 @@
112119 @Path("/{appid}")
113120 @Transactional
114121 @Consumes(MediaType.APPLICATION_JSON)
115
- @Produces({ MediaType.APPLICATION_JSON })
122
+ @Produces({
123
+ MediaType.APPLICATION_JSON
124
+ })
116125 public Response modify(Application app, @PathParam("appid") String appid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
117126 LOG.info("Modifying application with id: {}", appid);
118127 EntityManager em = emProvider.get();
....@@ -132,7 +141,9 @@
132141 @DELETE
133142 @Path("/{appid}")
134143 @Transactional
135
- @Produces({ MediaType.APPLICATION_JSON })
144
+ @Produces({
145
+ MediaType.APPLICATION_JSON
146
+ })
136147 public Response delete(@PathParam("appid") String appid, @Context HttpServletRequest request) {
137148 LOG.info("Deleting app with id: {}", appid);
138149 EntityManager em = emProvider.get();
....@@ -143,7 +154,7 @@
143154 .build();
144155 }
145156
146
- if (app.getLicenseTypes() != null && app.getLicenseTypes().size() > 0) {
157
+ if (app.getLicenseTypes() != null && !app.getLicenseTypes().isEmpty()) {
147158 return Response
148159 .status(Status.FORBIDDEN)
149160 .header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER,
securis/src/main/java/net/curisit/securis/services/BasicServices.java
....@@ -24,8 +24,8 @@
2424 import net.curisit.securis.security.Securable;
2525 import net.curisit.securis.utils.TokenHelper;
2626
27
-import org.apache.logging.log4j.Logger;
2827 import org.apache.logging.log4j.LogManager;
28
+import org.apache.logging.log4j.Logger;
2929
3030 /**
3131 * Basic services for login and basic app wrkflow
....@@ -42,18 +42,23 @@
4242 TokenHelper tokenHelper;
4343
4444 @Inject
45
- public BasicServices() {}
45
+ public BasicServices() {
46
+ }
4647
4748 @GET
4849 @Path("/info")
49
- @Produces({ MediaType.TEXT_PLAIN })
50
+ @Produces({
51
+ MediaType.TEXT_PLAIN
52
+ })
5053 public Response info(@Context HttpServletRequest request) {
5154 return Response.ok().entity("License server running OK. Date: " + new Date()).build();
5255 }
5356
5457 @GET
5558 @Path("/{module:(admin)|(login)|(licenses)}")
56
- @Produces({ MediaType.TEXT_HTML })
59
+ @Produces({
60
+ MediaType.TEXT_HTML
61
+ })
5762 public Response init(@PathParam("module") String module, @Context HttpServletRequest request) {
5863 LOG.info("App index main.html");
5964 String page = "/main.html";
....@@ -63,7 +68,9 @@
6368
6469 @POST
6570 @Path("/login")
66
- @Produces({ MediaType.APPLICATION_JSON })
71
+ @Produces({
72
+ MediaType.APPLICATION_JSON
73
+ })
6774 public Response login(@FormParam("username") String user, @FormParam("password") String password, @Context HttpServletRequest request) {
6875 LOG.info("index session: " + request.getSession());
6976 LOG.info("user: {}, pass: {}", user, password);
....@@ -88,7 +95,9 @@
8895 @GET
8996 @Securable()
9097 @Path("/check")
91
- @Produces({ MediaType.APPLICATION_JSON })
98
+ @Produces({
99
+ MediaType.APPLICATION_JSON
100
+ })
92101 public Response check(@HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token, @QueryParam("token") String token2) {
93102 if (token == null) {
94103 token = token2;
....@@ -110,7 +119,9 @@
110119 @GET
111120 @POST
112121 @Path("/logout")
113
- @Produces({ MediaType.APPLICATION_JSON })
122
+ @Produces({
123
+ MediaType.APPLICATION_JSON
124
+ })
114125 public Response logout(@HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
115126 if (token == null) {
116127 Response.status(Status.BAD_REQUEST).build();
securis/src/main/java/net/curisit/securis/services/LicenseResource.java
....@@ -33,9 +33,9 @@
3333 import net.curisit.securis.services.exception.SeCurisServiceException;
3434 import net.curisit.securis.utils.TokenHelper;
3535
36
-import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
37
-import org.apache.logging.log4j.Logger;
3836 import org.apache.logging.log4j.LogManager;
37
+import org.apache.logging.log4j.Logger;
38
+import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
3939
4040 import com.google.inject.persist.Transactional;
4141
....@@ -56,7 +56,8 @@
5656 @Inject
5757 Provider<EntityManager> emProvider;
5858
59
- public LicenseResource() {}
59
+ public LicenseResource() {
60
+ }
6061
6162 /**
6263 *
....@@ -65,7 +66,9 @@
6566 @GET
6667 @Path("/")
6768 @Securable
68
- @Produces({ MediaType.APPLICATION_JSON })
69
+ @Produces({
70
+ MediaType.APPLICATION_JSON
71
+ })
6972 public Response index(@QueryParam("packId") Integer packId, @Context BasicSecurityContext bsc) {
7073 LOG.info("Getting licenses list ");
7174
....@@ -97,7 +100,9 @@
97100 @GET
98101 @Path("/{licId}")
99102 @Securable
100
- @Produces({ MediaType.APPLICATION_JSON })
103
+ @Produces({
104
+ MediaType.APPLICATION_JSON
105
+ })
101106 public Response get(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
102107 LOG.info("Getting organization data for id: {}: ", licId);
103108
....@@ -114,7 +119,9 @@
114119 @GET
115120 @Path("/{licId}/download")
116121 @Securable
117
- @Produces({ MediaType.APPLICATION_OCTET_STREAM })
122
+ @Produces({
123
+ MediaType.APPLICATION_OCTET_STREAM
124
+ })
118125 public Response download(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
119126
120127 EntityManager em = emProvider.get();
....@@ -137,7 +144,9 @@
137144 @Securable
138145 @Transactional
139146 @Consumes(MediaType.APPLICATION_JSON)
140
- @Produces({ MediaType.APPLICATION_JSON })
147
+ @Produces({
148
+ MediaType.APPLICATION_JSON
149
+ })
141150 public Response activate(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
142151
143152 EntityManager em = emProvider.get();
....@@ -163,7 +172,9 @@
163172 @Securable
164173 @Transactional
165174 @Consumes(MediaType.APPLICATION_JSON)
166
- @Produces({ MediaType.APPLICATION_JSON })
175
+ @Produces({
176
+ MediaType.APPLICATION_JSON
177
+ })
167178 public Response send(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
168179
169180 EntityManager em = emProvider.get();
....@@ -183,7 +194,9 @@
183194 @Securable
184195 @Transactional
185196 @Consumes(MediaType.APPLICATION_JSON)
186
- @Produces({ MediaType.APPLICATION_JSON })
197
+ @Produces({
198
+ MediaType.APPLICATION_JSON
199
+ })
187200 public Response cancel(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
188201
189202 EntityManager em = emProvider.get();
....@@ -208,7 +221,9 @@
208221 @Path("/")
209222 @Consumes(MediaType.APPLICATION_JSON)
210223 @Securable
211
- @Produces({ MediaType.APPLICATION_JSON })
224
+ @Produces({
225
+ MediaType.APPLICATION_JSON
226
+ })
212227 @Transactional
213228 public Response create(License lic, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
214229 LOG.info("Creating new license from create()");
....@@ -221,12 +236,10 @@
221236 return Response.status(Status.NOT_FOUND)
222237 .header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's pack not found with ID: " + lic.getPackId()).build();
223238 } else {
224
- if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) {
225
- if (!bsc.getOrganizationsIds().contains(pack.getOrganization().getId())) {
226
- LOG.error("License for pack with id {} can not be created by user {}", pack.getId(), bsc.getUserPrincipal());
227
- return Response.status(Status.UNAUTHORIZED)
228
- .header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Unathorized action on pack license").build();
229
- }
239
+ if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN) && !bsc.getOrganizationsIds().contains(pack.getOrganization().getId())) {
240
+ LOG.error("License for pack with id {} can not be created by user {}", pack.getId(), bsc.getUserPrincipal());
241
+ return Response.status(Status.UNAUTHORIZED)
242
+ .header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Unathorized action on pack license").build();
230243 }
231244 }
232245 }
....@@ -248,7 +261,9 @@
248261 @Path("/")
249262 @Consumes(MediaType.MULTIPART_FORM_DATA)
250263 @Securable
251
- @Produces({ MediaType.APPLICATION_JSON })
264
+ @Produces({
265
+ MediaType.APPLICATION_JSON
266
+ })
252267 @Transactional
253268 public Response createWithFile(MultipartFormDataInput mpfdi, @Context BasicSecurityContext bsc) throws IOException, SeCurisServiceException {
254269 License lic = new License();
....@@ -268,7 +283,9 @@
268283 @Securable
269284 @Transactional
270285 @Consumes(MediaType.APPLICATION_JSON)
271
- @Produces({ MediaType.APPLICATION_JSON })
286
+ @Produces({
287
+ MediaType.APPLICATION_JSON
288
+ })
272289 public Response modify(License lic, @PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
273290 LOG.info("Modifying organization with id: {}", licId);
274291
....@@ -290,7 +307,9 @@
290307 @Path("/{licId}")
291308 @Transactional
292309 @Securable
293
- @Produces({ MediaType.APPLICATION_JSON })
310
+ @Produces({
311
+ MediaType.APPLICATION_JSON
312
+ })
294313 public Response delete(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
295314 LOG.info("Deleting license with id: {}", licId);
296315 EntityManager em = emProvider.get();
....@@ -317,11 +336,9 @@
317336 LOG.error("License with id {} not found in DB", licId);
318337 throw new SeCurisServiceException(Status.NOT_FOUND.getStatusCode(), "License not found for ID: " + licId);
319338 }
320
- if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) {
321
- if (!bsc.getOrganizationsIds().contains(lic.getPack().getOrganization().getId())) {
322
- LOG.error("License with id {} is not accesible by user {}", licId, bsc.getUserPrincipal());
323
- throw new SeCurisServiceException(Status.UNAUTHORIZED.getStatusCode(), "Unathorized access to license data");
324
- }
339
+ if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN) && !bsc.getOrganizationsIds().contains(lic.getPack().getOrganization().getId())) {
340
+ LOG.error("License with id {} is not accesible by user {}", licId, bsc.getUserPrincipal());
341
+ throw new SeCurisServiceException(Status.UNAUTHORIZED.getStatusCode(), "Unathorized access to license data");
325342 }
326343 return lic;
327344 }
securis/src/main/java/net/curisit/securis/services/LicenseServices.java
....@@ -23,10 +23,10 @@
2323 import net.curisit.integrity.beans.ServiceResponse;
2424
2525 import org.apache.commons.io.IOUtils;
26
+import org.apache.logging.log4j.LogManager;
27
+import org.apache.logging.log4j.Logger;
2628 import org.jboss.resteasy.annotations.providers.multipart.MultipartForm;
2729 import org.jboss.resteasy.annotations.providers.multipart.PartType;
28
-import org.apache.logging.log4j.Logger;
29
-import org.apache.logging.log4j.LogManager;
3030
3131 // The Java class will be hosted at the URI path "/myresource"
3232 @Path("/test")
....@@ -50,7 +50,9 @@
5050 * @return the server version in format majorVersion.minorVersion
5151 */
5252 @GET
53
- @Produces({ MediaType.TEXT_HTML })
53
+ @Produces({
54
+ MediaType.TEXT_HTML
55
+ })
5456 public Response index() {
5557 try {
5658 String index = IOUtils.toString(this.getClass().getResourceAsStream("/static/index.html"));
....@@ -63,7 +65,9 @@
6365
6466 @GET
6567 @Path("/dummy")
66
- @Produces({ MediaType.TEXT_PLAIN })
68
+ @Produces({
69
+ MediaType.TEXT_PLAIN
70
+ })
6771 public Response dummy(@Context HttpServletRequest request) {
6872 LOG.info("Request: " + request.getPathInfo());
6973 return Response.ok().entity((uri == null)).build();
....@@ -76,7 +80,9 @@
7680 @POST
7781 @Path("/upload1")
7882 @Consumes(MediaType.MULTIPART_FORM_DATA)
79
- @Produces({ MediaType.APPLICATION_JSON })
83
+ @Produces({
84
+ MediaType.APPLICATION_JSON
85
+ })
8086 public Response testFile1(@MultipartForm FileUploadForm mfdi) {
8187 LOG.info("FORM: texto: {}, file: {}", mfdi.getTexto(), new String(mfdi.getFile()));
8288 return Response.ok("OK").build();
....@@ -84,7 +90,9 @@
8490
8591 @GET
8692 @Path("/current/{license}")
87
- @Produces({ MediaType.APPLICATION_JSON })
93
+ @Produces({
94
+ MediaType.APPLICATION_JSON
95
+ })
8896 public ServiceResponse<ServerConfigVersions> testFile(@PathParam("license") String license,
8997 @DefaultValue("-1") @QueryParam("minorVersion") int minorVersion, @DefaultValue("-1") @QueryParam("majorVersion") int majorVersion) {
9098
....@@ -104,7 +112,8 @@
104112 @PartType("text/plain")
105113 private String texto;
106114
107
- public FileUploadForm() {}
115
+ public FileUploadForm() {
116
+ }
108117
109118 public byte[] getFile() {
110119 return file;
securis/src/main/java/net/curisit/securis/services/LicenseTypeResource.java
....@@ -29,8 +29,8 @@
2929 import net.curisit.securis.db.LicenseType;
3030 import net.curisit.securis.utils.TokenHelper;
3131
32
-import org.apache.logging.log4j.Logger;
3332 import org.apache.logging.log4j.LogManager;
33
+import org.apache.logging.log4j.Logger;
3434
3535 import com.google.inject.persist.Transactional;
3636
....@@ -51,7 +51,8 @@
5151 @Inject
5252 Provider<EntityManager> emProvider;
5353
54
- public LicenseTypeResource() {}
54
+ public LicenseTypeResource() {
55
+ }
5556
5657 /**
5758 *
....@@ -59,7 +60,9 @@
5960 */
6061 @GET
6162 @Path("/")
62
- @Produces({ MediaType.APPLICATION_JSON })
63
+ @Produces({
64
+ MediaType.APPLICATION_JSON
65
+ })
6366 public Response index() {
6467 LOG.info("Getting license types list ");
6568
....@@ -76,7 +79,9 @@
7679 */
7780 @GET
7881 @Path("/{ltid}")
79
- @Produces({ MediaType.APPLICATION_JSON })
82
+ @Produces({
83
+ MediaType.APPLICATION_JSON
84
+ })
8085 public Response get(@PathParam("ltid") String ltid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
8186 LOG.info("Getting license type data for id: {}: ", ltid);
8287 if (ltid == null || "".equals(ltid)) {
....@@ -96,7 +101,9 @@
96101 @POST
97102 @Path("/")
98103 @Consumes(MediaType.APPLICATION_JSON)
99
- @Produces({ MediaType.APPLICATION_JSON })
104
+ @Produces({
105
+ MediaType.APPLICATION_JSON
106
+ })
100107 @Transactional
101108 public Response create(LicenseType lt, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
102109 LOG.info("Creating new license type");
....@@ -125,7 +132,9 @@
125132 @Path("/{ltid}")
126133 @Transactional
127134 @Consumes(MediaType.APPLICATION_JSON)
128
- @Produces({ MediaType.APPLICATION_JSON })
135
+ @Produces({
136
+ MediaType.APPLICATION_JSON
137
+ })
129138 public Response modify(LicenseType lt, @PathParam("ltid") String ltid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
130139 LOG.info("Modifying license type with id: {}", ltid);
131140 EntityManager em = emProvider.get();
....@@ -166,7 +175,9 @@
166175 @DELETE
167176 @Path("/{ltid}")
168177 @Transactional
169
- @Produces({ MediaType.APPLICATION_JSON })
178
+ @Produces({
179
+ MediaType.APPLICATION_JSON
180
+ })
170181 public Response delete(@PathParam("ltid") String ltid, @Context HttpServletRequest request) {
171182 LOG.info("Deleting app with id: {}", ltid);
172183 EntityManager em = emProvider.get();
securis/src/main/java/net/curisit/securis/services/OrganizationResource.java
....@@ -33,9 +33,9 @@
3333 import net.curisit.securis.security.Securable;
3434 import net.curisit.securis.utils.TokenHelper;
3535
36
-import org.jboss.resteasy.spi.ResteasyProviderFactory;
37
-import org.apache.logging.log4j.Logger;
3836 import org.apache.logging.log4j.LogManager;
37
+import org.apache.logging.log4j.Logger;
38
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
3939
4040 import com.google.inject.persist.Transactional;
4141
....@@ -53,7 +53,8 @@
5353 @Inject
5454 private Provider<EntityManager> emProvider;
5555
56
- public OrganizationResource() {}
56
+ public OrganizationResource() {
57
+ }
5758
5859 /**
5960 *
....@@ -61,7 +62,9 @@
6162 */
6263 @GET
6364 @Path("/")
64
- @Produces({ MediaType.APPLICATION_JSON })
65
+ @Produces({
66
+ MediaType.APPLICATION_JSON
67
+ })
6568 @Securable
6669 public Response index(@Context BasicSecurityContext bsc) {
6770 LOG.info("Getting organizations list ");
....@@ -88,7 +91,9 @@
8891 */
8992 @GET
9093 @Path("/{orgid}")
91
- @Produces({ MediaType.APPLICATION_JSON })
94
+ @Produces({
95
+ MediaType.APPLICATION_JSON
96
+ })
9297 @Securable
9398 public Response get(@PathParam("orgid") String orgid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
9499 LOG.info("Getting organization data for id: {}: ", orgid);
....@@ -120,7 +125,9 @@
120125 @POST
121126 @Path("/")
122127 @Consumes(MediaType.APPLICATION_JSON)
123
- @Produces({ MediaType.APPLICATION_JSON })
128
+ @Produces({
129
+ MediaType.APPLICATION_JSON
130
+ })
124131 @Transactional
125132 @Securable
126133 @RolesAllowed(BasicSecurityContext.ROL_ADMIN)
....@@ -136,7 +143,7 @@
136143
137144 List<User> users = null;
138145 List<String> usersIds = org.getUsersIds();
139
- if (usersIds != null && usersIds.size() > 0) {
146
+ if (usersIds != null && !usersIds.isEmpty()) {
140147 users = new ArrayList<>();
141148 for (String username : usersIds) {
142149 User user = em.find(User.class, username);
....@@ -171,7 +178,7 @@
171178
172179 private void setOrgUsers(Organization org, List<String> usersIds, EntityManager em) throws SeCurisException {
173180 List<User> users = null;
174
- if (usersIds != null && usersIds.size() > 0) {
181
+ if (usersIds != null && !usersIds.isEmpty()) {
175182 users = new ArrayList<>();
176183 for (String username : usersIds) {
177184 User user = em.find(User.class, username);
....@@ -191,7 +198,9 @@
191198 @Path("/{orgid}")
192199 @Transactional
193200 @Consumes(MediaType.APPLICATION_JSON)
194
- @Produces({ MediaType.APPLICATION_JSON })
201
+ @Produces({
202
+ MediaType.APPLICATION_JSON
203
+ })
195204 @Securable
196205 @RolesAllowed(BasicSecurityContext.ROL_ADMIN)
197206 public Response modify(Organization org, @PathParam("orgid") String orgid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
....@@ -208,16 +217,13 @@
208217 } catch (SeCurisException e) {
209218 return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, e.getMessage()).build();
210219 }
211
- if (org.getParentOrganization() != null) {
212
- if (isCyclicalRelationship(currentOrg.getId(), org.getParentOrganization())) {
213
- LOG.error("Organization parent generate a cyclical relationship, parent id {}, current id: {}", org.getParentOrgId(),
214
- currentOrg.getId());
215
- return Response
216
- .status(Status.FORBIDDEN)
217
- .header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER,
218
- "Cyclical relationships are not allowed, please change the parent organization, current Parent: "
219
- + org.getParentOrganization().getName()).build();
220
- }
220
+ if (org.getParentOrganization() != null && (isCyclicalRelationship(currentOrg.getId(), org.getParentOrganization()))) {
221
+ LOG.error("Organization parent generate a cyclical relationship, parent id {}, current id: {}", org.getParentOrgId(), currentOrg.getId());
222
+ return Response
223
+ .status(Status.FORBIDDEN)
224
+ .header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER,
225
+ "Cyclical relationships are not allowed, please change the parent organization, current Parent: "
226
+ + org.getParentOrganization().getName()).build();
221227 }
222228
223229 try {
....@@ -237,7 +243,9 @@
237243 @DELETE
238244 @Path("/{orgid}")
239245 @Transactional
240
- @Produces({ MediaType.APPLICATION_JSON })
246
+ @Produces({
247
+ MediaType.APPLICATION_JSON
248
+ })
241249 @Securable
242250 @RolesAllowed(BasicSecurityContext.ROL_ADMIN)
243251 public Response delete(@PathParam("orgid") String orgid, @Context HttpServletRequest request) {
....@@ -249,7 +257,7 @@
249257 return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization was not found, ID: " + orgid)
250258 .build();
251259 }
252
- if (org.getChildOrganizations() != null && org.getChildOrganizations().size() > 0) {
260
+ if (org.getChildOrganizations() != null && !org.getChildOrganizations().isEmpty()) {
253261 LOG.error("Organization has children and can not be deleted, ID: " + orgid);
254262 return Response.status(Status.FORBIDDEN)
255263 .header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization has children and can not be deleted, ID: " + orgid).build();
securis/src/main/java/net/curisit/securis/services/PackResource.java
....@@ -5,7 +5,6 @@
55 import java.util.List;
66
77 import javax.annotation.security.RolesAllowed;
8
-import javax.crypto.SealedObject;
98 import javax.inject.Inject;
109 import javax.inject.Provider;
1110 import javax.persistence.EntityManager;
....@@ -34,8 +33,8 @@
3433 import net.curisit.securis.security.Securable;
3534 import net.curisit.securis.utils.TokenHelper;
3635
37
-import org.apache.logging.log4j.Logger;
3836 import org.apache.logging.log4j.LogManager;
37
+import org.apache.logging.log4j.Logger;
3938
4039 import com.google.inject.persist.Transactional;
4140
....@@ -56,7 +55,8 @@
5655 @Inject
5756 Provider<EntityManager> emProvider;
5857
59
- public PackResource() {}
58
+ public PackResource() {
59
+ }
6060
6161 /**
6262 *
....@@ -65,7 +65,9 @@
6565 @GET
6666 @Path("/")
6767 @Securable
68
- @Produces({ MediaType.APPLICATION_JSON })
68
+ @Produces({
69
+ MediaType.APPLICATION_JSON
70
+ })
6971 public Response index(@Context BasicSecurityContext bsc) {
7072 LOG.info("Getting packs list ");
7173
....@@ -100,7 +102,9 @@
100102 @GET
101103 @Path("/{packId}")
102104 @Securable
103
- @Produces({ MediaType.APPLICATION_JSON })
105
+ @Produces({
106
+ MediaType.APPLICATION_JSON
107
+ })
104108 public Response get(@PathParam("packId") Integer packId, @Context BasicSecurityContext bsc) {
105109 LOG.info("Getting pack data for id: {}: ", packId);
106110 if (packId == null || "".equals(packId)) {
....@@ -114,10 +118,9 @@
114118 LOG.error("Pack with id {} not found in DB", packId);
115119 return Response.status(Status.NOT_FOUND).build();
116120 }
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());
121124 }
122125 return Response.ok(pack).build();
123126 }
....@@ -127,7 +130,9 @@
127130 @Securable
128131 @RolesAllowed(BasicSecurityContext.ROL_ADMIN)
129132 @Consumes(MediaType.APPLICATION_JSON)
130
- @Produces({ MediaType.APPLICATION_JSON })
133
+ @Produces({
134
+ MediaType.APPLICATION_JSON
135
+ })
131136 @Transactional
132137 public Response create(Pack pack, @Context BasicSecurityContext bsc) {
133138 LOG.info("Creating new pack");
....@@ -173,7 +178,9 @@
173178 @Securable
174179 @RolesAllowed(BasicSecurityContext.ROL_ADMIN)
175180 @Consumes(MediaType.APPLICATION_JSON)
176
- @Produces({ MediaType.APPLICATION_JSON })
181
+ @Produces({
182
+ MediaType.APPLICATION_JSON
183
+ })
177184 public Response modify(Pack pack, @PathParam("packId") Integer packId) {
178185 LOG.info("Modifying pack with id: {}", packId);
179186 EntityManager em = emProvider.get();
....@@ -218,7 +225,9 @@
218225 @Securable
219226 @RolesAllowed(BasicSecurityContext.ROL_ADMIN)
220227 @Transactional
221
- @Produces({ MediaType.APPLICATION_JSON })
228
+ @Produces({
229
+ MediaType.APPLICATION_JSON
230
+ })
222231 public Response delete(@PathParam("packId") String packId) {
223232 LOG.info("Deleting pack with id: {}", packId);
224233 EntityManager em = emProvider.get();
securis/src/main/java/net/curisit/securis/services/UserResource.java
....@@ -33,8 +33,8 @@
3333 import net.curisit.securis.db.User;
3434 import net.curisit.securis.utils.TokenHelper;
3535
36
-import org.apache.logging.log4j.Logger;
3736 import org.apache.logging.log4j.LogManager;
37
+import org.apache.logging.log4j.Logger;
3838
3939 import com.google.inject.persist.Transactional;
4040
....@@ -54,7 +54,8 @@
5454
5555 private static final Logger LOG = LogManager.getLogger(UserResource.class);
5656
57
- public UserResource() {}
57
+ public UserResource() {
58
+ }
5859
5960 /**
6061 *
....@@ -62,7 +63,9 @@
6263 */
6364 @GET
6465 @Path("/")
65
- @Produces({ MediaType.APPLICATION_JSON })
66
+ @Produces({
67
+ MediaType.APPLICATION_JSON
68
+ })
6669 public Response index() {
6770 LOG.info("Getting users list ");
6871
....@@ -80,7 +83,9 @@
8083 */
8184 @GET
8285 @Path("/{uid}")
83
- @Produces({ MediaType.APPLICATION_JSON })
86
+ @Produces({
87
+ MediaType.APPLICATION_JSON
88
+ })
8489 public Response get(@PathParam("uid") String uid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
8590 LOG.info("Getting user data for id: {}: ", uid);
8691 if (uid == null || "".equals(uid)) {
....@@ -100,7 +105,9 @@
100105 @POST
101106 @Path("/")
102107 @Consumes(MediaType.APPLICATION_JSON)
103
- @Produces({ MediaType.APPLICATION_JSON })
108
+ @Produces({
109
+ MediaType.APPLICATION_JSON
110
+ })
104111 @Transactional
105112 public Response create(User user, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
106113 LOG.info("Creating new user");
....@@ -126,7 +133,7 @@
126133
127134 private void setUserOrg(User user, Set<Integer> orgsIds, EntityManager em) throws SeCurisException {
128135 Set<Organization> orgs = null;
129
- if (orgsIds != null && orgsIds.size() > 0) {
136
+ if (orgsIds != null && !orgsIds.isEmpty()) {
130137 orgs = new HashSet<>();
131138 for (Integer orgId : orgsIds) {
132139 Organization o = em.find(Organization.class, orgId);
....@@ -147,7 +154,9 @@
147154 @Path("/{uid}")
148155 @Transactional
149156 @Consumes(MediaType.APPLICATION_JSON)
150
- @Produces({ MediaType.APPLICATION_JSON })
157
+ @Produces({
158
+ MediaType.APPLICATION_JSON
159
+ })
151160 public Response modify(User user, @PathParam("uid") String uid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
152161 LOG.info("Modifying user with id: {}", uid);
153162 EntityManager em = emProvider.get();
....@@ -178,7 +187,9 @@
178187 @DELETE
179188 @Path("/{uid}")
180189 @Transactional
181
- @Produces({ MediaType.APPLICATION_JSON })
190
+ @Produces({
191
+ MediaType.APPLICATION_JSON
192
+ })
182193 public Response delete(@PathParam("uid") String uid, @Context HttpServletRequest request) {
183194 LOG.info("Deleting app with id: {}", uid);
184195 EntityManager em = emProvider.get();
....@@ -194,7 +205,9 @@
194205
195206 @POST
196207 @Path("/login")
197
- @Produces({ MediaType.APPLICATION_JSON })
208
+ @Produces({
209
+ MediaType.APPLICATION_JSON
210
+ })
198211 public Response login(@FormParam("username") String user, @FormParam("password") String password, @Context HttpServletRequest request) {
199212 LOG.info("index session: " + request.getSession());
200213 LOG.info("user: {}, pass: {}", user, password);
....@@ -218,7 +231,9 @@
218231 */
219232 @POST
220233 @Path("/check")
221
- @Produces({ MediaType.APPLICATION_JSON })
234
+ @Produces({
235
+ MediaType.APPLICATION_JSON
236
+ })
222237 public Response check(@HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token, @QueryParam("token") String token2) {
223238 if (token == null) {
224239 token = token2;
....@@ -241,7 +256,9 @@
241256
242257 @GET
243258 @Path("/logout")
244
- @Produces({ MediaType.APPLICATION_JSON })
259
+ @Produces({
260
+ MediaType.APPLICATION_JSON
261
+ })
245262 public Response logout(@Context HttpServletRequest request) {
246263 request.getSession().invalidate();
247264 return Response.ok().build();
securis/src/main/java/net/curisit/securis/utils/CacheTTL.java
....@@ -9,8 +9,8 @@
99 import javax.inject.Inject;
1010 import javax.inject.Singleton;
1111
12
-import org.apache.logging.log4j.Logger;
1312 import org.apache.logging.log4j.LogManager;
13
+import org.apache.logging.log4j.Logger;
1414
1515 /**
1616 * Cache implementation with TTL (time To Live) The objects are removed from
securis/src/main/java/net/curisit/securis/utils/TokenHelper.java
....@@ -13,9 +13,9 @@
1313 import net.curisit.integrity.commons.Utils;
1414
1515 import org.apache.commons.lang3.StringUtils;
16
-import org.jboss.resteasy.util.Base64;
17
-import org.apache.logging.log4j.Logger;
1816 import org.apache.logging.log4j.LogManager;
17
+import org.apache.logging.log4j.Logger;
18
+import org.jboss.resteasy.util.Base64;
1919
2020 @Singleton
2121 public class TokenHelper {
....@@ -29,7 +29,8 @@
2929 public static final String TOKEN_HEADER_PÀRAM = "X-SECURIS-TOKEN";
3030
3131 @Inject
32
- public TokenHelper() {}
32
+ public TokenHelper() {
33
+ }
3334
3435 private static byte[] seed = "S3Cur15S33dForT0k3nG3n3r@tion".getBytes();
3536
securis/src/patch/java/net/curisit/securis/LicenseGenerator.java
....@@ -37,7 +37,8 @@
3737
3838 private static LicenseGenerator singleton = new LicenseGenerator();
3939
40
- private LicenseGenerator() {}
40
+ private LicenseGenerator() {
41
+ }
4142
4243 public static LicenseGenerator getInstance() {
4344 return singleton;