#396 fix - Fixed more SonarQube issues, new code style applied
| .. | .. |
|---|
| 14 | 14 | import javax.servlet.http.HttpServletRequest; |
|---|
| 15 | 15 | import javax.servlet.http.HttpServletRequestWrapper; |
|---|
| 16 | 16 | |
|---|
| 17 | | -import org.apache.logging.log4j.Logger; |
|---|
| 18 | | - |
|---|
| 19 | 17 | import org.apache.logging.log4j.LogManager; |
|---|
| 18 | +import org.apache.logging.log4j.Logger; |
|---|
| 20 | 19 | |
|---|
| 21 | 20 | @Singleton |
|---|
| 22 | 21 | @WebFilter(urlPatterns = "/*") |
|---|
| .. | .. |
|---|
| 25 | 24 | private static final Logger LOG = LogManager.getLogger(AuthFilter.class); |
|---|
| 26 | 25 | |
|---|
| 27 | 26 | @Override |
|---|
| 28 | | - public void init(FilterConfig fc) throws ServletException {} |
|---|
| 27 | + public void init(FilterConfig fc) throws ServletException { |
|---|
| 28 | + } |
|---|
| 29 | 29 | |
|---|
| 30 | 30 | @Override |
|---|
| 31 | 31 | public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) throws IOException, ServletException { |
|---|
| .. | .. |
|---|
| 47 | 47 | } |
|---|
| 48 | 48 | |
|---|
| 49 | 49 | @Override |
|---|
| 50 | | - public void destroy() {} |
|---|
| 50 | + public void destroy() { |
|---|
| 51 | + } |
|---|
| 51 | 52 | |
|---|
| 52 | 53 | private class UserRoleRequestWrapper extends HttpServletRequestWrapper { |
|---|
| 53 | 54 | |
|---|
| .. | .. |
|---|
| 83 | 84 | }; |
|---|
| 84 | 85 | } |
|---|
| 85 | 86 | } |
|---|
| 86 | | -} |
|---|
| 87 | +} |
|---|
| .. | .. |
|---|
| 12 | 12 | |
|---|
| 13 | 13 | import net.curisit.securis.services.exception.SeCurisServiceException; |
|---|
| 14 | 14 | |
|---|
| 15 | | -import org.apache.logging.log4j.Logger; |
|---|
| 16 | 15 | import org.apache.logging.log4j.LogManager; |
|---|
| 16 | +import org.apache.logging.log4j.Logger; |
|---|
| 17 | 17 | |
|---|
| 18 | 18 | @Provider |
|---|
| 19 | 19 | public class DefaultExceptionHandler implements ExceptionMapper<Exception> { |
|---|
| .. | .. |
|---|
| 49 | 49 | LOG.error("Request url: " + request.getRequestURL(), e); |
|---|
| 50 | 50 | return Response.serverError().header(ERROR_MESSAGE_HEADER, "Unexpected error: " + e.toString()).type(MediaType.APPLICATION_JSON).build(); |
|---|
| 51 | 51 | } |
|---|
| 52 | | -} |
|---|
| 52 | +} |
|---|
| .. | .. |
|---|
| 9 | 9 | import net.curisit.securis.ioc.RequestsModule;
|
|---|
| 10 | 10 | import net.curisit.securis.ioc.SecurisModule;
|
|---|
| 11 | 11 |
|
|---|
| 12 | +import org.apache.logging.log4j.LogManager;
|
|---|
| 13 | +import org.apache.logging.log4j.Logger;
|
|---|
| 12 | 14 | import org.eclipse.jetty.server.Handler;
|
|---|
| 13 | 15 | import org.eclipse.jetty.server.Server;
|
|---|
| 14 | 16 | import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
|---|
| .. | .. |
|---|
| 20 | 22 | import org.eclipse.jetty.util.resource.Resource;
|
|---|
| 21 | 23 | import org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener;
|
|---|
| 22 | 24 | import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher;
|
|---|
| 23 | | -import org.apache.logging.log4j.Logger;
|
|---|
| 24 | | -import org.apache.logging.log4j.LogManager;
|
|---|
| 25 | 25 |
|
|---|
| 26 | 26 | import com.google.inject.Guice;
|
|---|
| 27 | 27 | import com.google.inject.Injector;
|
|---|
| .. | .. |
|---|
| 77 | 77 |
|
|---|
| 78 | 78 | ResourceHandler staticResources = new ResourceHandler();
|
|---|
| 79 | 79 | 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 | + });
|
|---|
| 81 | 83 | context.setHandler(staticResources);
|
|---|
| 82 | 84 |
|
|---|
| 83 | 85 | ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
|
|---|
| .. | .. |
|---|
| 85 | 87 | LOG.info("Error Handlers: " + context.getErrorHandler());
|
|---|
| 86 | 88 | ContextHandlerCollection contexts = new ContextHandlerCollection();
|
|---|
| 87 | 89 |
|
|---|
| 88 | | - contexts.setHandlers(new Handler[] { staticResources, context });
|
|---|
| 90 | + contexts.setHandlers(new Handler[] {
|
|---|
| 91 | + staticResources, context
|
|---|
| 92 | + });
|
|---|
| 89 | 93 |
|
|---|
| 90 | 94 | server.setHandler(context);
|
|---|
| 91 | 95 | server.start();
|
|---|
| .. | .. |
|---|
| 8 | 8 | import net.curisit.securis.services.BasicServices;
|
|---|
| 9 | 9 | import net.curisit.securis.services.LicenseServices;
|
|---|
| 10 | 10 |
|
|---|
| 11 | | -import org.apache.logging.log4j.Logger;
|
|---|
| 12 | 11 | import org.apache.logging.log4j.LogManager;
|
|---|
| 12 | +import org.apache.logging.log4j.Logger;
|
|---|
| 13 | 13 |
|
|---|
| 14 | 14 | public class RestServicesApplication extends Application {
|
|---|
| 15 | 15 |
|
|---|
| .. | .. |
|---|
| 15 | 15 | public class UserDao { |
|---|
| 16 | 16 | |
|---|
| 17 | 17 | @Inject |
|---|
| 18 | | - public UserDao() {} |
|---|
| 18 | + public UserDao() { |
|---|
| 19 | + } |
|---|
| 19 | 20 | |
|---|
| 20 | 21 | @Inject |
|---|
| 21 | 22 | Provider<EntityManager> emProvider; |
|---|
| .. | .. |
|---|
| 26 | 26 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) |
|---|
| 27 | 27 | @Entity |
|---|
| 28 | 28 | @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 | +}) |
|---|
| 30 | 32 | public class Application implements Serializable { |
|---|
| 31 | 33 | |
|---|
| 32 | 34 | private static final long serialVersionUID = 1L; |
|---|
| .. | .. |
|---|
| 35 | 35 | @Entity |
|---|
| 36 | 36 | @Table(name = "license") |
|---|
| 37 | 37 | @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 | +}) |
|---|
| 39 | 41 | public class License implements Serializable { |
|---|
| 40 | 42 | |
|---|
| 41 | 43 | private static final long serialVersionUID = 1L; |
|---|
| .. | .. |
|---|
| 27 | 27 | @Entity |
|---|
| 28 | 28 | @Table(name = "license_history") |
|---|
| 29 | 29 | @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 | +}) |
|---|
| 31 | 33 | public class LicenseHistory implements Serializable { |
|---|
| 32 | 34 | |
|---|
| 33 | 35 | private static final long serialVersionUID = 1L; |
|---|
| .. | .. |
|---|
| 13 | 13 | import javax.persistence.NamedQuery; |
|---|
| 14 | 14 | import javax.persistence.Table; |
|---|
| 15 | 15 | |
|---|
| 16 | +import org.apache.logging.log4j.LogManager; |
|---|
| 17 | +import org.apache.logging.log4j.Logger; |
|---|
| 16 | 18 | import org.codehaus.jackson.annotate.JsonAutoDetect; |
|---|
| 17 | 19 | import org.codehaus.jackson.annotate.JsonIgnore; |
|---|
| 18 | 20 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; |
|---|
| 19 | 21 | import org.codehaus.jackson.annotate.JsonProperty; |
|---|
| 20 | 22 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
|---|
| 21 | | -import org.apache.logging.log4j.Logger; |
|---|
| 22 | | -import org.apache.logging.log4j.LogManager; |
|---|
| 23 | 23 | |
|---|
| 24 | 24 | /** |
|---|
| 25 | 25 | * Entity implementation class for Entity: license_type |
|---|
| .. | .. |
|---|
| 30 | 30 | @JsonIgnoreProperties(ignoreUnknown = true) |
|---|
| 31 | 31 | @Entity |
|---|
| 32 | 32 | @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 | +}) |
|---|
| 34 | 36 | public class LicenseType implements Serializable { |
|---|
| 35 | 37 | |
|---|
| 36 | 38 | private static final Logger LOG = LogManager.getLogger(LicenseType.class); |
|---|
| .. | .. |
|---|
| 21 | 21 | import javax.persistence.OneToMany; |
|---|
| 22 | 22 | import javax.persistence.Table; |
|---|
| 23 | 23 | |
|---|
| 24 | +import org.apache.logging.log4j.LogManager; |
|---|
| 25 | +import org.apache.logging.log4j.Logger; |
|---|
| 24 | 26 | import org.codehaus.jackson.annotate.JsonAutoDetect; |
|---|
| 25 | 27 | import org.codehaus.jackson.annotate.JsonIgnore; |
|---|
| 26 | 28 | import org.codehaus.jackson.annotate.JsonProperty; |
|---|
| 27 | 29 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
|---|
| 28 | | -import org.apache.logging.log4j.Logger; |
|---|
| 29 | | -import org.apache.logging.log4j.LogManager; |
|---|
| 30 | 30 | |
|---|
| 31 | 31 | /** |
|---|
| 32 | 32 | * Entity implementation class for Entity: organization |
|---|
| .. | .. |
|---|
| 36 | 36 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) |
|---|
| 37 | 37 | @Entity |
|---|
| 38 | 38 | @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"), |
|---|
| 40 | 41 | @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 | +}) |
|---|
| 42 | 44 | public class Organization implements Serializable { |
|---|
| 43 | 45 | |
|---|
| 44 | 46 | @SuppressWarnings("unused") |
|---|
| .. | .. |
|---|
| 61 | 63 | // We don't include the users to limit the size of each row a the listing |
|---|
| 62 | 64 | @ManyToMany(cascade = CascadeType.REMOVE) |
|---|
| 63 | 65 | @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 | + }) |
|---|
| 66 | 72 | private List<User> users; |
|---|
| 67 | 73 | |
|---|
| 68 | 74 | @JsonIgnore |
|---|
| .. | .. |
|---|
| 32 | 32 | @Entity |
|---|
| 33 | 33 | @Table(name = "pack") |
|---|
| 34 | 34 | @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 | +}) |
|---|
| 37 | 39 | public class Pack implements Serializable { |
|---|
| 38 | 40 | |
|---|
| 39 | 41 | private static final long serialVersionUID = 1L; |
|---|
| .. | .. |
|---|
| 30 | 30 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) |
|---|
| 31 | 31 | @Entity |
|---|
| 32 | 32 | @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"), |
|---|
| 34 | 35 | @NamedQuery(name = "get-user", query = "SELECT u FROM User u where u.username = :username"), |
|---|
| 35 | 36 | @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 | +}) |
|---|
| 37 | 39 | public class User implements Serializable { |
|---|
| 38 | 40 | |
|---|
| 39 | 41 | private static final long serialVersionUID = 1L; |
|---|
| .. | .. |
|---|
| 67 | 69 | @JsonIgnore |
|---|
| 68 | 70 | @ManyToMany |
|---|
| 69 | 71 | @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 | + } // |
|---|
| 72 | 78 | ) |
|---|
| 73 | 79 | private Set<Organization> organizations; |
|---|
| 74 | 80 | |
|---|
| .. | .. |
|---|
| 214 | 220 | public static class Rol { |
|---|
| 215 | 221 | public static final int ADVANCE = 0x01; |
|---|
| 216 | 222 | 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 | + }; |
|---|
| 218 | 226 | } |
|---|
| 219 | 227 | |
|---|
| 220 | 228 | } |
|---|
| .. | .. |
|---|
| 13 | 13 | import javax.ws.rs.core.UriBuilder; |
|---|
| 14 | 14 | import javax.ws.rs.core.UriBuilderException; |
|---|
| 15 | 15 | |
|---|
| 16 | | -import org.h2.jdbcx.JdbcDataSource; |
|---|
| 17 | | -import org.apache.logging.log4j.Logger; |
|---|
| 18 | 16 | import org.apache.logging.log4j.LogManager; |
|---|
| 17 | +import org.apache.logging.log4j.Logger; |
|---|
| 18 | +import org.h2.jdbcx.JdbcDataSource; |
|---|
| 19 | 19 | |
|---|
| 20 | 20 | import com.google.inject.AbstractModule; |
|---|
| 21 | 21 | import com.google.inject.Provides; |
|---|
| .. | .. |
|---|
| 19 | 19 | * Bit mask with the rol or roles necessary to access the method |
|---|
| 20 | 20 | */ |
|---|
| 21 | 21 | int roles() default 0; |
|---|
| 22 | | -} |
|---|
| 22 | +} |
|---|
| .. | .. |
|---|
| 21 | 21 | import net.curisit.securis.utils.CacheTTL; |
|---|
| 22 | 22 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 23 | 23 | |
|---|
| 24 | +import org.apache.logging.log4j.LogManager; |
|---|
| 25 | +import org.apache.logging.log4j.Logger; |
|---|
| 24 | 26 | import org.jboss.resteasy.core.Dispatcher; |
|---|
| 25 | 27 | import org.jboss.resteasy.core.ResourceMethodInvoker; |
|---|
| 26 | 28 | import org.jboss.resteasy.core.ServerResponse; |
|---|
| 27 | 29 | import org.jboss.resteasy.spi.Failure; |
|---|
| 28 | 30 | import org.jboss.resteasy.spi.HttpRequest; |
|---|
| 29 | 31 | import org.jboss.resteasy.spi.ResteasyProviderFactory; |
|---|
| 30 | | -import org.apache.logging.log4j.Logger; |
|---|
| 31 | | -import org.apache.logging.log4j.LogManager; |
|---|
| 32 | 32 | |
|---|
| 33 | 33 | @Provider |
|---|
| 34 | 34 | // @PreMatching |
|---|
| .. | .. |
|---|
| 11 | 11 | |
|---|
| 12 | 12 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 13 | 13 | |
|---|
| 14 | | -import org.apache.logging.log4j.Logger; |
|---|
| 15 | 14 | import org.apache.logging.log4j.LogManager; |
|---|
| 15 | +import org.apache.logging.log4j.Logger; |
|---|
| 16 | 16 | |
|---|
| 17 | 17 | /** |
|---|
| 18 | 18 | * External API to be accessed by third parties |
|---|
| .. | .. |
|---|
| 31 | 31 | @Inject |
|---|
| 32 | 32 | Provider<EntityManager> emProvider; |
|---|
| 33 | 33 | |
|---|
| 34 | | - public ApiResource() {} |
|---|
| 34 | + public ApiResource() { |
|---|
| 35 | + } |
|---|
| 35 | 36 | |
|---|
| 36 | 37 | /** |
|---|
| 37 | 38 | * |
|---|
| .. | .. |
|---|
| 39 | 40 | */ |
|---|
| 40 | 41 | @GET |
|---|
| 41 | 42 | @Path("/") |
|---|
| 42 | | - @Produces({ MediaType.TEXT_PLAIN }) |
|---|
| 43 | + @Produces({ |
|---|
| 44 | + MediaType.TEXT_PLAIN |
|---|
| 45 | + }) |
|---|
| 43 | 46 | public Response index() { |
|---|
| 44 | 47 | return Response.ok("SeCuris API").build(); |
|---|
| 45 | 48 | } |
|---|
| .. | .. |
|---|
| 27 | 27 | import net.curisit.securis.db.Application; |
|---|
| 28 | 28 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 29 | 29 | |
|---|
| 30 | | -import org.apache.logging.log4j.Logger; |
|---|
| 31 | 30 | import org.apache.logging.log4j.LogManager; |
|---|
| 31 | +import org.apache.logging.log4j.Logger; |
|---|
| 32 | 32 | |
|---|
| 33 | 33 | import com.google.inject.persist.Transactional; |
|---|
| 34 | 34 | |
|---|
| .. | .. |
|---|
| 49 | 49 | |
|---|
| 50 | 50 | private static final Logger LOG = LogManager.getLogger(ApplicationResource.class); |
|---|
| 51 | 51 | |
|---|
| 52 | | - public ApplicationResource() {} |
|---|
| 52 | + public ApplicationResource() { |
|---|
| 53 | + } |
|---|
| 53 | 54 | |
|---|
| 54 | 55 | /** |
|---|
| 55 | 56 | * |
|---|
| .. | .. |
|---|
| 57 | 58 | */ |
|---|
| 58 | 59 | @GET |
|---|
| 59 | 60 | @Path("/") |
|---|
| 60 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 61 | + @Produces({ |
|---|
| 62 | + MediaType.APPLICATION_JSON |
|---|
| 63 | + }) |
|---|
| 61 | 64 | public Response index() { |
|---|
| 62 | 65 | LOG.info("Getting applications list "); |
|---|
| 63 | 66 | |
|---|
| .. | .. |
|---|
| 74 | 77 | */ |
|---|
| 75 | 78 | @GET |
|---|
| 76 | 79 | @Path("/{appid}") |
|---|
| 77 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 80 | + @Produces({ |
|---|
| 81 | + MediaType.APPLICATION_JSON |
|---|
| 82 | + }) |
|---|
| 78 | 83 | public Response get(@PathParam("appid") String appid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 79 | 84 | LOG.info("Getting application data for id: {}: ", appid); |
|---|
| 80 | 85 | if (appid == null || "".equals(appid)) { |
|---|
| .. | .. |
|---|
| 96 | 101 | @POST |
|---|
| 97 | 102 | @Path("/") |
|---|
| 98 | 103 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 99 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 104 | + @Produces({ |
|---|
| 105 | + MediaType.APPLICATION_JSON |
|---|
| 106 | + }) |
|---|
| 100 | 107 | @Transactional |
|---|
| 101 | 108 | public Response create(Application app, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 102 | 109 | LOG.info("Creating new application"); |
|---|
| .. | .. |
|---|
| 112 | 119 | @Path("/{appid}") |
|---|
| 113 | 120 | @Transactional |
|---|
| 114 | 121 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 115 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 122 | + @Produces({ |
|---|
| 123 | + MediaType.APPLICATION_JSON |
|---|
| 124 | + }) |
|---|
| 116 | 125 | public Response modify(Application app, @PathParam("appid") String appid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 117 | 126 | LOG.info("Modifying application with id: {}", appid); |
|---|
| 118 | 127 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 132 | 141 | @DELETE |
|---|
| 133 | 142 | @Path("/{appid}") |
|---|
| 134 | 143 | @Transactional |
|---|
| 135 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 144 | + @Produces({ |
|---|
| 145 | + MediaType.APPLICATION_JSON |
|---|
| 146 | + }) |
|---|
| 136 | 147 | public Response delete(@PathParam("appid") String appid, @Context HttpServletRequest request) { |
|---|
| 137 | 148 | LOG.info("Deleting app with id: {}", appid); |
|---|
| 138 | 149 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 143 | 154 | .build(); |
|---|
| 144 | 155 | } |
|---|
| 145 | 156 | |
|---|
| 146 | | - if (app.getLicenseTypes() != null && app.getLicenseTypes().size() > 0) { |
|---|
| 157 | + if (app.getLicenseTypes() != null && !app.getLicenseTypes().isEmpty()) { |
|---|
| 147 | 158 | return Response |
|---|
| 148 | 159 | .status(Status.FORBIDDEN) |
|---|
| 149 | 160 | .header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, |
|---|
| .. | .. |
|---|
| 24 | 24 | import net.curisit.securis.security.Securable; |
|---|
| 25 | 25 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 26 | 26 | |
|---|
| 27 | | -import org.apache.logging.log4j.Logger; |
|---|
| 28 | 27 | import org.apache.logging.log4j.LogManager; |
|---|
| 28 | +import org.apache.logging.log4j.Logger; |
|---|
| 29 | 29 | |
|---|
| 30 | 30 | /** |
|---|
| 31 | 31 | * Basic services for login and basic app wrkflow |
|---|
| .. | .. |
|---|
| 42 | 42 | TokenHelper tokenHelper; |
|---|
| 43 | 43 | |
|---|
| 44 | 44 | @Inject |
|---|
| 45 | | - public BasicServices() {} |
|---|
| 45 | + public BasicServices() { |
|---|
| 46 | + } |
|---|
| 46 | 47 | |
|---|
| 47 | 48 | @GET |
|---|
| 48 | 49 | @Path("/info") |
|---|
| 49 | | - @Produces({ MediaType.TEXT_PLAIN }) |
|---|
| 50 | + @Produces({ |
|---|
| 51 | + MediaType.TEXT_PLAIN |
|---|
| 52 | + }) |
|---|
| 50 | 53 | public Response info(@Context HttpServletRequest request) { |
|---|
| 51 | 54 | return Response.ok().entity("License server running OK. Date: " + new Date()).build(); |
|---|
| 52 | 55 | } |
|---|
| 53 | 56 | |
|---|
| 54 | 57 | @GET |
|---|
| 55 | 58 | @Path("/{module:(admin)|(login)|(licenses)}") |
|---|
| 56 | | - @Produces({ MediaType.TEXT_HTML }) |
|---|
| 59 | + @Produces({ |
|---|
| 60 | + MediaType.TEXT_HTML |
|---|
| 61 | + }) |
|---|
| 57 | 62 | public Response init(@PathParam("module") String module, @Context HttpServletRequest request) { |
|---|
| 58 | 63 | LOG.info("App index main.html"); |
|---|
| 59 | 64 | String page = "/main.html"; |
|---|
| .. | .. |
|---|
| 63 | 68 | |
|---|
| 64 | 69 | @POST |
|---|
| 65 | 70 | @Path("/login") |
|---|
| 66 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 71 | + @Produces({ |
|---|
| 72 | + MediaType.APPLICATION_JSON |
|---|
| 73 | + }) |
|---|
| 67 | 74 | public Response login(@FormParam("username") String user, @FormParam("password") String password, @Context HttpServletRequest request) { |
|---|
| 68 | 75 | LOG.info("index session: " + request.getSession()); |
|---|
| 69 | 76 | LOG.info("user: {}, pass: {}", user, password); |
|---|
| .. | .. |
|---|
| 88 | 95 | @GET |
|---|
| 89 | 96 | @Securable() |
|---|
| 90 | 97 | @Path("/check") |
|---|
| 91 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 98 | + @Produces({ |
|---|
| 99 | + MediaType.APPLICATION_JSON |
|---|
| 100 | + }) |
|---|
| 92 | 101 | public Response check(@HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token, @QueryParam("token") String token2) { |
|---|
| 93 | 102 | if (token == null) { |
|---|
| 94 | 103 | token = token2; |
|---|
| .. | .. |
|---|
| 110 | 119 | @GET |
|---|
| 111 | 120 | @POST |
|---|
| 112 | 121 | @Path("/logout") |
|---|
| 113 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 122 | + @Produces({ |
|---|
| 123 | + MediaType.APPLICATION_JSON |
|---|
| 124 | + }) |
|---|
| 114 | 125 | public Response logout(@HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 115 | 126 | if (token == null) { |
|---|
| 116 | 127 | Response.status(Status.BAD_REQUEST).build(); |
|---|
| .. | .. |
|---|
| 33 | 33 | import net.curisit.securis.services.exception.SeCurisServiceException; |
|---|
| 34 | 34 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 35 | 35 | |
|---|
| 36 | | -import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; |
|---|
| 37 | | -import org.apache.logging.log4j.Logger; |
|---|
| 38 | 36 | import org.apache.logging.log4j.LogManager; |
|---|
| 37 | +import org.apache.logging.log4j.Logger; |
|---|
| 38 | +import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; |
|---|
| 39 | 39 | |
|---|
| 40 | 40 | import com.google.inject.persist.Transactional; |
|---|
| 41 | 41 | |
|---|
| .. | .. |
|---|
| 56 | 56 | @Inject |
|---|
| 57 | 57 | Provider<EntityManager> emProvider; |
|---|
| 58 | 58 | |
|---|
| 59 | | - public LicenseResource() {} |
|---|
| 59 | + public LicenseResource() { |
|---|
| 60 | + } |
|---|
| 60 | 61 | |
|---|
| 61 | 62 | /** |
|---|
| 62 | 63 | * |
|---|
| .. | .. |
|---|
| 65 | 66 | @GET |
|---|
| 66 | 67 | @Path("/") |
|---|
| 67 | 68 | @Securable |
|---|
| 68 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 69 | + @Produces({ |
|---|
| 70 | + MediaType.APPLICATION_JSON |
|---|
| 71 | + }) |
|---|
| 69 | 72 | public Response index(@QueryParam("packId") Integer packId, @Context BasicSecurityContext bsc) { |
|---|
| 70 | 73 | LOG.info("Getting licenses list "); |
|---|
| 71 | 74 | |
|---|
| .. | .. |
|---|
| 97 | 100 | @GET |
|---|
| 98 | 101 | @Path("/{licId}") |
|---|
| 99 | 102 | @Securable |
|---|
| 100 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 103 | + @Produces({ |
|---|
| 104 | + MediaType.APPLICATION_JSON |
|---|
| 105 | + }) |
|---|
| 101 | 106 | public Response get(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 102 | 107 | LOG.info("Getting organization data for id: {}: ", licId); |
|---|
| 103 | 108 | |
|---|
| .. | .. |
|---|
| 114 | 119 | @GET |
|---|
| 115 | 120 | @Path("/{licId}/download") |
|---|
| 116 | 121 | @Securable |
|---|
| 117 | | - @Produces({ MediaType.APPLICATION_OCTET_STREAM }) |
|---|
| 122 | + @Produces({ |
|---|
| 123 | + MediaType.APPLICATION_OCTET_STREAM |
|---|
| 124 | + }) |
|---|
| 118 | 125 | public Response download(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 119 | 126 | |
|---|
| 120 | 127 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 137 | 144 | @Securable |
|---|
| 138 | 145 | @Transactional |
|---|
| 139 | 146 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 140 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 147 | + @Produces({ |
|---|
| 148 | + MediaType.APPLICATION_JSON |
|---|
| 149 | + }) |
|---|
| 141 | 150 | public Response activate(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 142 | 151 | |
|---|
| 143 | 152 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 163 | 172 | @Securable |
|---|
| 164 | 173 | @Transactional |
|---|
| 165 | 174 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 166 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 175 | + @Produces({ |
|---|
| 176 | + MediaType.APPLICATION_JSON |
|---|
| 177 | + }) |
|---|
| 167 | 178 | public Response send(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 168 | 179 | |
|---|
| 169 | 180 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 183 | 194 | @Securable |
|---|
| 184 | 195 | @Transactional |
|---|
| 185 | 196 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 186 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 197 | + @Produces({ |
|---|
| 198 | + MediaType.APPLICATION_JSON |
|---|
| 199 | + }) |
|---|
| 187 | 200 | public Response cancel(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 188 | 201 | |
|---|
| 189 | 202 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 208 | 221 | @Path("/") |
|---|
| 209 | 222 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 210 | 223 | @Securable |
|---|
| 211 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 224 | + @Produces({ |
|---|
| 225 | + MediaType.APPLICATION_JSON |
|---|
| 226 | + }) |
|---|
| 212 | 227 | @Transactional |
|---|
| 213 | 228 | public Response create(License lic, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 214 | 229 | LOG.info("Creating new license from create()"); |
|---|
| .. | .. |
|---|
| 221 | 236 | return Response.status(Status.NOT_FOUND) |
|---|
| 222 | 237 | .header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's pack not found with ID: " + lic.getPackId()).build(); |
|---|
| 223 | 238 | } 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(); |
|---|
| 230 | 243 | } |
|---|
| 231 | 244 | } |
|---|
| 232 | 245 | } |
|---|
| .. | .. |
|---|
| 248 | 261 | @Path("/") |
|---|
| 249 | 262 | @Consumes(MediaType.MULTIPART_FORM_DATA) |
|---|
| 250 | 263 | @Securable |
|---|
| 251 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 264 | + @Produces({ |
|---|
| 265 | + MediaType.APPLICATION_JSON |
|---|
| 266 | + }) |
|---|
| 252 | 267 | @Transactional |
|---|
| 253 | 268 | public Response createWithFile(MultipartFormDataInput mpfdi, @Context BasicSecurityContext bsc) throws IOException, SeCurisServiceException { |
|---|
| 254 | 269 | License lic = new License(); |
|---|
| .. | .. |
|---|
| 268 | 283 | @Securable |
|---|
| 269 | 284 | @Transactional |
|---|
| 270 | 285 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 271 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 286 | + @Produces({ |
|---|
| 287 | + MediaType.APPLICATION_JSON |
|---|
| 288 | + }) |
|---|
| 272 | 289 | public Response modify(License lic, @PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 273 | 290 | LOG.info("Modifying organization with id: {}", licId); |
|---|
| 274 | 291 | |
|---|
| .. | .. |
|---|
| 290 | 307 | @Path("/{licId}") |
|---|
| 291 | 308 | @Transactional |
|---|
| 292 | 309 | @Securable |
|---|
| 293 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 310 | + @Produces({ |
|---|
| 311 | + MediaType.APPLICATION_JSON |
|---|
| 312 | + }) |
|---|
| 294 | 313 | public Response delete(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 295 | 314 | LOG.info("Deleting license with id: {}", licId); |
|---|
| 296 | 315 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 317 | 336 | LOG.error("License with id {} not found in DB", licId); |
|---|
| 318 | 337 | throw new SeCurisServiceException(Status.NOT_FOUND.getStatusCode(), "License not found for ID: " + licId); |
|---|
| 319 | 338 | } |
|---|
| 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"); |
|---|
| 325 | 342 | } |
|---|
| 326 | 343 | return lic; |
|---|
| 327 | 344 | } |
|---|
| .. | .. |
|---|
| 23 | 23 | import net.curisit.integrity.beans.ServiceResponse; |
|---|
| 24 | 24 | |
|---|
| 25 | 25 | import org.apache.commons.io.IOUtils; |
|---|
| 26 | +import org.apache.logging.log4j.LogManager; |
|---|
| 27 | +import org.apache.logging.log4j.Logger; |
|---|
| 26 | 28 | import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; |
|---|
| 27 | 29 | import org.jboss.resteasy.annotations.providers.multipart.PartType; |
|---|
| 28 | | -import org.apache.logging.log4j.Logger; |
|---|
| 29 | | -import org.apache.logging.log4j.LogManager; |
|---|
| 30 | 30 | |
|---|
| 31 | 31 | // The Java class will be hosted at the URI path "/myresource" |
|---|
| 32 | 32 | @Path("/test") |
|---|
| .. | .. |
|---|
| 50 | 50 | * @return the server version in format majorVersion.minorVersion |
|---|
| 51 | 51 | */ |
|---|
| 52 | 52 | @GET |
|---|
| 53 | | - @Produces({ MediaType.TEXT_HTML }) |
|---|
| 53 | + @Produces({ |
|---|
| 54 | + MediaType.TEXT_HTML |
|---|
| 55 | + }) |
|---|
| 54 | 56 | public Response index() { |
|---|
| 55 | 57 | try { |
|---|
| 56 | 58 | String index = IOUtils.toString(this.getClass().getResourceAsStream("/static/index.html")); |
|---|
| .. | .. |
|---|
| 63 | 65 | |
|---|
| 64 | 66 | @GET |
|---|
| 65 | 67 | @Path("/dummy") |
|---|
| 66 | | - @Produces({ MediaType.TEXT_PLAIN }) |
|---|
| 68 | + @Produces({ |
|---|
| 69 | + MediaType.TEXT_PLAIN |
|---|
| 70 | + }) |
|---|
| 67 | 71 | public Response dummy(@Context HttpServletRequest request) { |
|---|
| 68 | 72 | LOG.info("Request: " + request.getPathInfo()); |
|---|
| 69 | 73 | return Response.ok().entity((uri == null)).build(); |
|---|
| .. | .. |
|---|
| 76 | 80 | @POST |
|---|
| 77 | 81 | @Path("/upload1") |
|---|
| 78 | 82 | @Consumes(MediaType.MULTIPART_FORM_DATA) |
|---|
| 79 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 83 | + @Produces({ |
|---|
| 84 | + MediaType.APPLICATION_JSON |
|---|
| 85 | + }) |
|---|
| 80 | 86 | public Response testFile1(@MultipartForm FileUploadForm mfdi) { |
|---|
| 81 | 87 | LOG.info("FORM: texto: {}, file: {}", mfdi.getTexto(), new String(mfdi.getFile())); |
|---|
| 82 | 88 | return Response.ok("OK").build(); |
|---|
| .. | .. |
|---|
| 84 | 90 | |
|---|
| 85 | 91 | @GET |
|---|
| 86 | 92 | @Path("/current/{license}") |
|---|
| 87 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 93 | + @Produces({ |
|---|
| 94 | + MediaType.APPLICATION_JSON |
|---|
| 95 | + }) |
|---|
| 88 | 96 | public ServiceResponse<ServerConfigVersions> testFile(@PathParam("license") String license, |
|---|
| 89 | 97 | @DefaultValue("-1") @QueryParam("minorVersion") int minorVersion, @DefaultValue("-1") @QueryParam("majorVersion") int majorVersion) { |
|---|
| 90 | 98 | |
|---|
| .. | .. |
|---|
| 104 | 112 | @PartType("text/plain") |
|---|
| 105 | 113 | private String texto; |
|---|
| 106 | 114 | |
|---|
| 107 | | - public FileUploadForm() {} |
|---|
| 115 | + public FileUploadForm() { |
|---|
| 116 | + } |
|---|
| 108 | 117 | |
|---|
| 109 | 118 | public byte[] getFile() { |
|---|
| 110 | 119 | return file; |
|---|
| .. | .. |
|---|
| 29 | 29 | import net.curisit.securis.db.LicenseType; |
|---|
| 30 | 30 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 31 | 31 | |
|---|
| 32 | | -import org.apache.logging.log4j.Logger; |
|---|
| 33 | 32 | import org.apache.logging.log4j.LogManager; |
|---|
| 33 | +import org.apache.logging.log4j.Logger; |
|---|
| 34 | 34 | |
|---|
| 35 | 35 | import com.google.inject.persist.Transactional; |
|---|
| 36 | 36 | |
|---|
| .. | .. |
|---|
| 51 | 51 | @Inject |
|---|
| 52 | 52 | Provider<EntityManager> emProvider; |
|---|
| 53 | 53 | |
|---|
| 54 | | - public LicenseTypeResource() {} |
|---|
| 54 | + public LicenseTypeResource() { |
|---|
| 55 | + } |
|---|
| 55 | 56 | |
|---|
| 56 | 57 | /** |
|---|
| 57 | 58 | * |
|---|
| .. | .. |
|---|
| 59 | 60 | */ |
|---|
| 60 | 61 | @GET |
|---|
| 61 | 62 | @Path("/") |
|---|
| 62 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 63 | + @Produces({ |
|---|
| 64 | + MediaType.APPLICATION_JSON |
|---|
| 65 | + }) |
|---|
| 63 | 66 | public Response index() { |
|---|
| 64 | 67 | LOG.info("Getting license types list "); |
|---|
| 65 | 68 | |
|---|
| .. | .. |
|---|
| 76 | 79 | */ |
|---|
| 77 | 80 | @GET |
|---|
| 78 | 81 | @Path("/{ltid}") |
|---|
| 79 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 82 | + @Produces({ |
|---|
| 83 | + MediaType.APPLICATION_JSON |
|---|
| 84 | + }) |
|---|
| 80 | 85 | public Response get(@PathParam("ltid") String ltid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 81 | 86 | LOG.info("Getting license type data for id: {}: ", ltid); |
|---|
| 82 | 87 | if (ltid == null || "".equals(ltid)) { |
|---|
| .. | .. |
|---|
| 96 | 101 | @POST |
|---|
| 97 | 102 | @Path("/") |
|---|
| 98 | 103 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 99 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 104 | + @Produces({ |
|---|
| 105 | + MediaType.APPLICATION_JSON |
|---|
| 106 | + }) |
|---|
| 100 | 107 | @Transactional |
|---|
| 101 | 108 | public Response create(LicenseType lt, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 102 | 109 | LOG.info("Creating new license type"); |
|---|
| .. | .. |
|---|
| 125 | 132 | @Path("/{ltid}") |
|---|
| 126 | 133 | @Transactional |
|---|
| 127 | 134 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 128 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 135 | + @Produces({ |
|---|
| 136 | + MediaType.APPLICATION_JSON |
|---|
| 137 | + }) |
|---|
| 129 | 138 | public Response modify(LicenseType lt, @PathParam("ltid") String ltid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 130 | 139 | LOG.info("Modifying license type with id: {}", ltid); |
|---|
| 131 | 140 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 166 | 175 | @DELETE |
|---|
| 167 | 176 | @Path("/{ltid}") |
|---|
| 168 | 177 | @Transactional |
|---|
| 169 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 178 | + @Produces({ |
|---|
| 179 | + MediaType.APPLICATION_JSON |
|---|
| 180 | + }) |
|---|
| 170 | 181 | public Response delete(@PathParam("ltid") String ltid, @Context HttpServletRequest request) { |
|---|
| 171 | 182 | LOG.info("Deleting app with id: {}", ltid); |
|---|
| 172 | 183 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 33 | 33 | import net.curisit.securis.security.Securable; |
|---|
| 34 | 34 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 35 | 35 | |
|---|
| 36 | | -import org.jboss.resteasy.spi.ResteasyProviderFactory; |
|---|
| 37 | | -import org.apache.logging.log4j.Logger; |
|---|
| 38 | 36 | import org.apache.logging.log4j.LogManager; |
|---|
| 37 | +import org.apache.logging.log4j.Logger; |
|---|
| 38 | +import org.jboss.resteasy.spi.ResteasyProviderFactory; |
|---|
| 39 | 39 | |
|---|
| 40 | 40 | import com.google.inject.persist.Transactional; |
|---|
| 41 | 41 | |
|---|
| .. | .. |
|---|
| 53 | 53 | @Inject |
|---|
| 54 | 54 | private Provider<EntityManager> emProvider; |
|---|
| 55 | 55 | |
|---|
| 56 | | - public OrganizationResource() {} |
|---|
| 56 | + public OrganizationResource() { |
|---|
| 57 | + } |
|---|
| 57 | 58 | |
|---|
| 58 | 59 | /** |
|---|
| 59 | 60 | * |
|---|
| .. | .. |
|---|
| 61 | 62 | */ |
|---|
| 62 | 63 | @GET |
|---|
| 63 | 64 | @Path("/") |
|---|
| 64 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 65 | + @Produces({ |
|---|
| 66 | + MediaType.APPLICATION_JSON |
|---|
| 67 | + }) |
|---|
| 65 | 68 | @Securable |
|---|
| 66 | 69 | public Response index(@Context BasicSecurityContext bsc) { |
|---|
| 67 | 70 | LOG.info("Getting organizations list "); |
|---|
| .. | .. |
|---|
| 88 | 91 | */ |
|---|
| 89 | 92 | @GET |
|---|
| 90 | 93 | @Path("/{orgid}") |
|---|
| 91 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 94 | + @Produces({ |
|---|
| 95 | + MediaType.APPLICATION_JSON |
|---|
| 96 | + }) |
|---|
| 92 | 97 | @Securable |
|---|
| 93 | 98 | public Response get(@PathParam("orgid") String orgid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 94 | 99 | LOG.info("Getting organization data for id: {}: ", orgid); |
|---|
| .. | .. |
|---|
| 120 | 125 | @POST |
|---|
| 121 | 126 | @Path("/") |
|---|
| 122 | 127 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 123 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 128 | + @Produces({ |
|---|
| 129 | + MediaType.APPLICATION_JSON |
|---|
| 130 | + }) |
|---|
| 124 | 131 | @Transactional |
|---|
| 125 | 132 | @Securable |
|---|
| 126 | 133 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| .. | .. |
|---|
| 136 | 143 | |
|---|
| 137 | 144 | List<User> users = null; |
|---|
| 138 | 145 | List<String> usersIds = org.getUsersIds(); |
|---|
| 139 | | - if (usersIds != null && usersIds.size() > 0) { |
|---|
| 146 | + if (usersIds != null && !usersIds.isEmpty()) { |
|---|
| 140 | 147 | users = new ArrayList<>(); |
|---|
| 141 | 148 | for (String username : usersIds) { |
|---|
| 142 | 149 | User user = em.find(User.class, username); |
|---|
| .. | .. |
|---|
| 171 | 178 | |
|---|
| 172 | 179 | private void setOrgUsers(Organization org, List<String> usersIds, EntityManager em) throws SeCurisException { |
|---|
| 173 | 180 | List<User> users = null; |
|---|
| 174 | | - if (usersIds != null && usersIds.size() > 0) { |
|---|
| 181 | + if (usersIds != null && !usersIds.isEmpty()) { |
|---|
| 175 | 182 | users = new ArrayList<>(); |
|---|
| 176 | 183 | for (String username : usersIds) { |
|---|
| 177 | 184 | User user = em.find(User.class, username); |
|---|
| .. | .. |
|---|
| 191 | 198 | @Path("/{orgid}") |
|---|
| 192 | 199 | @Transactional |
|---|
| 193 | 200 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 194 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 201 | + @Produces({ |
|---|
| 202 | + MediaType.APPLICATION_JSON |
|---|
| 203 | + }) |
|---|
| 195 | 204 | @Securable |
|---|
| 196 | 205 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 197 | 206 | public Response modify(Organization org, @PathParam("orgid") String orgid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| .. | .. |
|---|
| 208 | 217 | } catch (SeCurisException e) { |
|---|
| 209 | 218 | return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, e.getMessage()).build(); |
|---|
| 210 | 219 | } |
|---|
| 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(); |
|---|
| 221 | 227 | } |
|---|
| 222 | 228 | |
|---|
| 223 | 229 | try { |
|---|
| .. | .. |
|---|
| 237 | 243 | @DELETE |
|---|
| 238 | 244 | @Path("/{orgid}") |
|---|
| 239 | 245 | @Transactional |
|---|
| 240 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 246 | + @Produces({ |
|---|
| 247 | + MediaType.APPLICATION_JSON |
|---|
| 248 | + }) |
|---|
| 241 | 249 | @Securable |
|---|
| 242 | 250 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 243 | 251 | public Response delete(@PathParam("orgid") String orgid, @Context HttpServletRequest request) { |
|---|
| .. | .. |
|---|
| 249 | 257 | return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization was not found, ID: " + orgid) |
|---|
| 250 | 258 | .build(); |
|---|
| 251 | 259 | } |
|---|
| 252 | | - if (org.getChildOrganizations() != null && org.getChildOrganizations().size() > 0) { |
|---|
| 260 | + if (org.getChildOrganizations() != null && !org.getChildOrganizations().isEmpty()) { |
|---|
| 253 | 261 | LOG.error("Organization has children and can not be deleted, ID: " + orgid); |
|---|
| 254 | 262 | return Response.status(Status.FORBIDDEN) |
|---|
| 255 | 263 | .header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Organization has children and can not be deleted, ID: " + orgid).build(); |
|---|
| .. | .. |
|---|
| 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(); |
|---|
| .. | .. |
|---|
| 33 | 33 | import net.curisit.securis.db.User; |
|---|
| 34 | 34 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 35 | 35 | |
|---|
| 36 | | -import org.apache.logging.log4j.Logger; |
|---|
| 37 | 36 | import org.apache.logging.log4j.LogManager; |
|---|
| 37 | +import org.apache.logging.log4j.Logger; |
|---|
| 38 | 38 | |
|---|
| 39 | 39 | import com.google.inject.persist.Transactional; |
|---|
| 40 | 40 | |
|---|
| .. | .. |
|---|
| 54 | 54 | |
|---|
| 55 | 55 | private static final Logger LOG = LogManager.getLogger(UserResource.class); |
|---|
| 56 | 56 | |
|---|
| 57 | | - public UserResource() {} |
|---|
| 57 | + public UserResource() { |
|---|
| 58 | + } |
|---|
| 58 | 59 | |
|---|
| 59 | 60 | /** |
|---|
| 60 | 61 | * |
|---|
| .. | .. |
|---|
| 62 | 63 | */ |
|---|
| 63 | 64 | @GET |
|---|
| 64 | 65 | @Path("/") |
|---|
| 65 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 66 | + @Produces({ |
|---|
| 67 | + MediaType.APPLICATION_JSON |
|---|
| 68 | + }) |
|---|
| 66 | 69 | public Response index() { |
|---|
| 67 | 70 | LOG.info("Getting users list "); |
|---|
| 68 | 71 | |
|---|
| .. | .. |
|---|
| 80 | 83 | */ |
|---|
| 81 | 84 | @GET |
|---|
| 82 | 85 | @Path("/{uid}") |
|---|
| 83 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 86 | + @Produces({ |
|---|
| 87 | + MediaType.APPLICATION_JSON |
|---|
| 88 | + }) |
|---|
| 84 | 89 | public Response get(@PathParam("uid") String uid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 85 | 90 | LOG.info("Getting user data for id: {}: ", uid); |
|---|
| 86 | 91 | if (uid == null || "".equals(uid)) { |
|---|
| .. | .. |
|---|
| 100 | 105 | @POST |
|---|
| 101 | 106 | @Path("/") |
|---|
| 102 | 107 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 103 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 108 | + @Produces({ |
|---|
| 109 | + MediaType.APPLICATION_JSON |
|---|
| 110 | + }) |
|---|
| 104 | 111 | @Transactional |
|---|
| 105 | 112 | public Response create(User user, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 106 | 113 | LOG.info("Creating new user"); |
|---|
| .. | .. |
|---|
| 126 | 133 | |
|---|
| 127 | 134 | private void setUserOrg(User user, Set<Integer> orgsIds, EntityManager em) throws SeCurisException { |
|---|
| 128 | 135 | Set<Organization> orgs = null; |
|---|
| 129 | | - if (orgsIds != null && orgsIds.size() > 0) { |
|---|
| 136 | + if (orgsIds != null && !orgsIds.isEmpty()) { |
|---|
| 130 | 137 | orgs = new HashSet<>(); |
|---|
| 131 | 138 | for (Integer orgId : orgsIds) { |
|---|
| 132 | 139 | Organization o = em.find(Organization.class, orgId); |
|---|
| .. | .. |
|---|
| 147 | 154 | @Path("/{uid}") |
|---|
| 148 | 155 | @Transactional |
|---|
| 149 | 156 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 150 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 157 | + @Produces({ |
|---|
| 158 | + MediaType.APPLICATION_JSON |
|---|
| 159 | + }) |
|---|
| 151 | 160 | public Response modify(User user, @PathParam("uid") String uid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 152 | 161 | LOG.info("Modifying user with id: {}", uid); |
|---|
| 153 | 162 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 178 | 187 | @DELETE |
|---|
| 179 | 188 | @Path("/{uid}") |
|---|
| 180 | 189 | @Transactional |
|---|
| 181 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 190 | + @Produces({ |
|---|
| 191 | + MediaType.APPLICATION_JSON |
|---|
| 192 | + }) |
|---|
| 182 | 193 | public Response delete(@PathParam("uid") String uid, @Context HttpServletRequest request) { |
|---|
| 183 | 194 | LOG.info("Deleting app with id: {}", uid); |
|---|
| 184 | 195 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 194 | 205 | |
|---|
| 195 | 206 | @POST |
|---|
| 196 | 207 | @Path("/login") |
|---|
| 197 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 208 | + @Produces({ |
|---|
| 209 | + MediaType.APPLICATION_JSON |
|---|
| 210 | + }) |
|---|
| 198 | 211 | public Response login(@FormParam("username") String user, @FormParam("password") String password, @Context HttpServletRequest request) { |
|---|
| 199 | 212 | LOG.info("index session: " + request.getSession()); |
|---|
| 200 | 213 | LOG.info("user: {}, pass: {}", user, password); |
|---|
| .. | .. |
|---|
| 218 | 231 | */ |
|---|
| 219 | 232 | @POST |
|---|
| 220 | 233 | @Path("/check") |
|---|
| 221 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 234 | + @Produces({ |
|---|
| 235 | + MediaType.APPLICATION_JSON |
|---|
| 236 | + }) |
|---|
| 222 | 237 | public Response check(@HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token, @QueryParam("token") String token2) { |
|---|
| 223 | 238 | if (token == null) { |
|---|
| 224 | 239 | token = token2; |
|---|
| .. | .. |
|---|
| 241 | 256 | |
|---|
| 242 | 257 | @GET |
|---|
| 243 | 258 | @Path("/logout") |
|---|
| 244 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 259 | + @Produces({ |
|---|
| 260 | + MediaType.APPLICATION_JSON |
|---|
| 261 | + }) |
|---|
| 245 | 262 | public Response logout(@Context HttpServletRequest request) { |
|---|
| 246 | 263 | request.getSession().invalidate(); |
|---|
| 247 | 264 | return Response.ok().build(); |
|---|
| .. | .. |
|---|
| 9 | 9 | import javax.inject.Inject; |
|---|
| 10 | 10 | import javax.inject.Singleton; |
|---|
| 11 | 11 | |
|---|
| 12 | | -import org.apache.logging.log4j.Logger; |
|---|
| 13 | 12 | import org.apache.logging.log4j.LogManager; |
|---|
| 13 | +import org.apache.logging.log4j.Logger; |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | /** |
|---|
| 16 | 16 | * Cache implementation with TTL (time To Live) The objects are removed from |
|---|
| .. | .. |
|---|
| 13 | 13 | import net.curisit.integrity.commons.Utils; |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | import org.apache.commons.lang3.StringUtils; |
|---|
| 16 | | -import org.jboss.resteasy.util.Base64; |
|---|
| 17 | | -import org.apache.logging.log4j.Logger; |
|---|
| 18 | 16 | import org.apache.logging.log4j.LogManager; |
|---|
| 17 | +import org.apache.logging.log4j.Logger; |
|---|
| 18 | +import org.jboss.resteasy.util.Base64; |
|---|
| 19 | 19 | |
|---|
| 20 | 20 | @Singleton |
|---|
| 21 | 21 | public class TokenHelper { |
|---|
| .. | .. |
|---|
| 29 | 29 | public static final String TOKEN_HEADER_PÀRAM = "X-SECURIS-TOKEN"; |
|---|
| 30 | 30 | |
|---|
| 31 | 31 | @Inject |
|---|
| 32 | | - public TokenHelper() {} |
|---|
| 32 | + public TokenHelper() { |
|---|
| 33 | + } |
|---|
| 33 | 34 | |
|---|
| 34 | 35 | private static byte[] seed = "S3Cur15S33dForT0k3nG3n3r@tion".getBytes(); |
|---|
| 35 | 36 | |
|---|
| .. | .. |
|---|
| 37 | 37 | |
|---|
| 38 | 38 | private static LicenseGenerator singleton = new LicenseGenerator(); |
|---|
| 39 | 39 | |
|---|
| 40 | | - private LicenseGenerator() {} |
|---|
| 40 | + private LicenseGenerator() { |
|---|
| 41 | + } |
|---|
| 41 | 42 | |
|---|
| 42 | 43 | public static LicenseGenerator getInstance() { |
|---|
| 43 | 44 | return singleton; |
|---|