#0 refactoring - Removing Google Guice by CDI standard
2 files deleted
4 files added
24 files modified
| .. | .. |
|---|
| 19 | 19 | </dependency> |
|---|
| 20 | 20 | <dependency> |
|---|
| 21 | 21 | <groupId>org.jboss.resteasy</groupId> |
|---|
| 22 | | - <artifactId>resteasy-guice</artifactId> |
|---|
| 23 | | - <version>3.0.9.Final</version> |
|---|
| 24 | | - </dependency> |
|---|
| 25 | | - <dependency> |
|---|
| 26 | | - <groupId>org.jboss.resteasy</groupId> |
|---|
| 27 | 22 | <artifactId>resteasy-multipart-provider</artifactId> |
|---|
| 28 | | - <version>3.0.9.Final</version> |
|---|
| 23 | + <version>3.0.10.Final</version> |
|---|
| 29 | 24 | </dependency> |
|---|
| 30 | 25 | <dependency> |
|---|
| 31 | 26 | <groupId>org.jboss.resteasy</groupId> |
|---|
| 32 | 27 | <artifactId>resteasy-jaxrs</artifactId> |
|---|
| 33 | | - <version>3.0.9.Final</version> |
|---|
| 28 | + <version>3.0.10.Final</version> |
|---|
| 34 | 29 | </dependency> |
|---|
| 30 | +<dependency> |
|---|
| 31 | + <groupId>org.jboss.weld.servlet</groupId> |
|---|
| 32 | + <artifactId>weld-servlet</artifactId> |
|---|
| 33 | + <version>2.2.9.Final</version> |
|---|
| 34 | +</dependency> |
|---|
| 35 | +<dependency> |
|---|
| 36 | + <groupId>org.jboss</groupId> |
|---|
| 37 | + <artifactId>jandex</artifactId> |
|---|
| 38 | + <version>1.2.2.Final</version> |
|---|
| 39 | +</dependency> |
|---|
| 35 | 40 | <dependency> |
|---|
| 36 | 41 | <groupId>net.curisit</groupId> |
|---|
| 37 | 42 | <artifactId>commons-curis</artifactId> |
|---|
| .. | .. |
|---|
| 48 | 53 | <version>1.0.4-SNAPSHOT</version> |
|---|
| 49 | 54 | </dependency> |
|---|
| 50 | 55 | <dependency> |
|---|
| 51 | | - <groupId>org.hibernate</groupId> |
|---|
| 52 | | - <artifactId>hibernate-c3p0</artifactId> |
|---|
| 53 | | - <version>4.3.6.Final</version> |
|---|
| 54 | | - </dependency> |
|---|
| 55 | | - <dependency> |
|---|
| 56 | 56 | <groupId>org.apache.httpcomponents</groupId> |
|---|
| 57 | 57 | <artifactId>httpclient</artifactId> |
|---|
| 58 | 58 | <version>4.4-beta1</version> |
|---|
| .. | .. |
|---|
| 65 | 65 | <dependency> |
|---|
| 66 | 66 | <groupId>org.jboss.resteasy</groupId> |
|---|
| 67 | 67 | <artifactId>resteasy-jackson2-provider</artifactId> |
|---|
| 68 | | - <version>3.0.9.Final</version> |
|---|
| 68 | + <version>3.0.10.Final</version> |
|---|
| 69 | 69 | </dependency> |
|---|
| 70 | 70 | <dependency> |
|---|
| 71 | 71 | <groupId>org.apache.logging.log4j</groupId> |
|---|
| 72 | 72 | <artifactId>log4j-web</artifactId> |
|---|
| 73 | 73 | <version>2.1</version> |
|---|
| 74 | + </dependency> |
|---|
| 75 | + <dependency> |
|---|
| 76 | + <groupId>javax.enterprise</groupId> |
|---|
| 77 | + <artifactId>cdi-api</artifactId> |
|---|
| 78 | + <version>1.2</version> |
|---|
| 79 | + <scope>provided</scope> |
|---|
| 80 | +</dependency> |
|---|
| 81 | + <dependency> |
|---|
| 82 | + <groupId>org.jboss.resteasy</groupId> |
|---|
| 83 | + <artifactId>resteasy-cdi</artifactId> |
|---|
| 84 | + <version>3.0.10.Final</version> |
|---|
| 74 | 85 | </dependency> |
|---|
| 75 | 86 | </dependencies> |
|---|
| 76 | 87 | <build> |
|---|
| .. | .. |
|---|
| 117 | 128 | <url>http://archiva.curisit.net/archiva/repository/snapshots/</url> |
|---|
| 118 | 129 | <layout>default</layout> |
|---|
| 119 | 130 | </repository> |
|---|
| 131 | + <repository> |
|---|
| 132 | + <id>project.local</id> |
|---|
| 133 | + <name>project</name> |
|---|
| 134 | + <url>file:/opt/repo</url> |
|---|
| 135 | + </repository> |
|---|
| 120 | 136 | </repositories> |
|---|
| 121 | 137 | |
|---|
| 122 | 138 | </project> |
|---|
| .. | .. |
|---|
| 3 | 3 | import java.io.IOException; |
|---|
| 4 | 4 | import java.security.Principal; |
|---|
| 5 | 5 | |
|---|
| 6 | | -import javax.inject.Singleton; |
|---|
| 6 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 7 | 7 | import javax.servlet.Filter; |
|---|
| 8 | 8 | import javax.servlet.FilterChain; |
|---|
| 9 | 9 | import javax.servlet.FilterConfig; |
|---|
| .. | .. |
|---|
| 17 | 17 | import org.apache.logging.log4j.LogManager; |
|---|
| 18 | 18 | import org.apache.logging.log4j.Logger; |
|---|
| 19 | 19 | |
|---|
| 20 | | -@Singleton |
|---|
| 20 | +@ApplicationScoped |
|---|
| 21 | 21 | @WebFilter(urlPatterns = "/*") |
|---|
| 22 | 22 | public class AuthFilter implements Filter { |
|---|
| 23 | 23 | |
|---|
deleted file mode 100644| .. | .. |
|---|
| 1 | | -package net.curisit.securis; |
|---|
| 2 | | - |
|---|
| 3 | | -import java.util.List; |
|---|
| 4 | | - |
|---|
| 5 | | -import javax.servlet.ServletContext; |
|---|
| 6 | | -import javax.servlet.ServletContextEvent; |
|---|
| 7 | | - |
|---|
| 8 | | -import org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener; |
|---|
| 9 | | - |
|---|
| 10 | | -import com.google.inject.Injector; |
|---|
| 11 | | -import com.google.inject.Module; |
|---|
| 12 | | -import com.google.inject.persist.PersistService; |
|---|
| 13 | | -import com.google.inject.persist.jpa.JpaPersistModule; |
|---|
| 14 | | - |
|---|
| 15 | | -public class BootstrapListener extends GuiceResteasyBootstrapServletContextListener { |
|---|
| 16 | | - |
|---|
| 17 | | - @Override |
|---|
| 18 | | - public void contextInitialized(ServletContextEvent event) { |
|---|
| 19 | | - try { |
|---|
| 20 | | - super.contextInitialized(event); |
|---|
| 21 | | - } catch (Exception ex) { |
|---|
| 22 | | - ex.printStackTrace(); |
|---|
| 23 | | - } |
|---|
| 24 | | - } |
|---|
| 25 | | - |
|---|
| 26 | | - @SuppressWarnings("unchecked") |
|---|
| 27 | | - @Override |
|---|
| 28 | | - protected List<Module> getModules(ServletContext context) { |
|---|
| 29 | | - List<Module> modules = (List<Module>) super.getModules(context); |
|---|
| 30 | | - modules.add(new JpaPersistModule("localdb")); |
|---|
| 31 | | - return modules; |
|---|
| 32 | | - } |
|---|
| 33 | | - |
|---|
| 34 | | - @Override |
|---|
| 35 | | - public void withInjector(Injector injector) { |
|---|
| 36 | | - injector.getInstance(PersistService.class).start(); |
|---|
| 37 | | - } |
|---|
| 38 | | - |
|---|
| 39 | | -} |
|---|
| .. | .. |
|---|
| 24 | 24 | import org.apache.logging.log4j.LogManager; |
|---|
| 25 | 25 | import org.apache.logging.log4j.Logger; |
|---|
| 26 | 26 | |
|---|
| 27 | | -import com.google.inject.Singleton; |
|---|
| 28 | | - |
|---|
| 29 | 27 | /** |
|---|
| 30 | 28 | * License generator and signer |
|---|
| 31 | 29 | * |
|---|
| 32 | 30 | * @author roberto <roberto.sanchez@curisit.net> |
|---|
| 33 | 31 | */ |
|---|
| 34 | | -@Singleton |
|---|
| 32 | +@javax.inject.Singleton |
|---|
| 35 | 33 | public class LicenseGenerator { |
|---|
| 36 | 34 | |
|---|
| 37 | 35 | private static final Logger LOG = LogManager.getLogger(LicenseGenerator.class); |
|---|
| .. | .. |
|---|
| 3 | 3 | import java.util.HashSet;
|
|---|
| 4 | 4 | import java.util.Set;
|
|---|
| 5 | 5 |
|
|---|
| 6 | +import javax.inject.Inject;
|
|---|
| 7 | +import javax.ws.rs.ApplicationPath;
|
|---|
| 6 | 8 | import javax.ws.rs.core.Application;
|
|---|
| 7 | 9 |
|
|---|
| 8 | | -import net.curisit.integrity.commons.Utils;
|
|---|
| 10 | +import net.curisit.securis.ioc.DatabaseProvider;
|
|---|
| 11 | +import net.curisit.securis.ioc.TransactionsManager;
|
|---|
| 12 | +import net.curisit.securis.security.SecurityInterceptor;
|
|---|
| 13 | +import net.curisit.securis.services.ApiResource;
|
|---|
| 14 | +import net.curisit.securis.services.ApplicationResource;
|
|---|
| 15 | +import net.curisit.securis.services.BasicServices;
|
|---|
| 16 | +import net.curisit.securis.services.LicenseResource;
|
|---|
| 17 | +import net.curisit.securis.services.LicenseTypeResource;
|
|---|
| 18 | +import net.curisit.securis.services.OrganizationResource;
|
|---|
| 19 | +import net.curisit.securis.services.PackResource;
|
|---|
| 20 | +import net.curisit.securis.services.UserResource;
|
|---|
| 9 | 21 |
|
|---|
| 10 | 22 | import org.apache.logging.log4j.LogManager;
|
|---|
| 11 | 23 | import org.apache.logging.log4j.Logger;
|
|---|
| 12 | 24 |
|
|---|
| 25 | +@ApplicationPath("/")
|
|---|
| 13 | 26 | public class RestServicesApplication extends Application {
|
|---|
| 14 | 27 |
|
|---|
| 15 | 28 | private static final Logger LOG = LogManager.getLogger(RestServicesApplication.class);
|
|---|
| 29 | +
|
|---|
| 30 | + @Inject
|
|---|
| 31 | + private DatabaseProvider dp;
|
|---|
| 16 | 32 |
|
|---|
| 17 | 33 | @Override
|
|---|
| 18 | 34 | public Set<Class<?>> getClasses() {
|
|---|
| 19 | 35 | Set<Class<?>> classes = new HashSet<>();
|
|---|
| 20 | 36 | // classes.add(LicenseServices.class);
|
|---|
| 21 | | - // classes.add(BasicServices.class);
|
|---|
| 37 | + classes.add(UserResource.class);
|
|---|
| 38 | + classes.add(ApiResource.class);
|
|---|
| 39 | + classes.add(LicenseResource.class);
|
|---|
| 40 | + classes.add(BasicServices.class);
|
|---|
| 41 | + classes.add(ApplicationResource.class);
|
|---|
| 42 | + classes.add(OrganizationResource.class);
|
|---|
| 43 | + classes.add(LicenseTypeResource.class);
|
|---|
| 44 | + classes.add(PackResource.class);
|
|---|
| 45 | + classes.add(SecurityInterceptor.class);
|
|---|
| 46 | + classes.add(TransactionsManager.class);
|
|---|
| 22 | 47 |
|
|---|
| 23 | | - LOG.info("Returnes classes for services: {}", classes);
|
|---|
| 48 | + LOG.info("Returned classes for services: {}", classes);
|
|---|
| 49 | + LOG.info("dp: {}", dp);
|
|---|
| 24 | 50 | return classes;
|
|---|
| 25 | 51 | }
|
|---|
| 26 | 52 |
|
|---|
| 27 | | - public static void main(String[] args) {
|
|---|
| 28 | | - System.out.println("sha256: " + Utils.sha256("jdoe"));
|
|---|
| 29 | | - }
|
|---|
| 30 | 53 | }
|
|---|
| .. | .. |
|---|
| 3 | 3 | import java.util.Arrays; |
|---|
| 4 | 4 | import java.util.Date; |
|---|
| 5 | 5 | |
|---|
| 6 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 6 | 7 | import javax.inject.Inject; |
|---|
| 7 | 8 | import javax.inject.Provider; |
|---|
| 8 | | -import javax.inject.Singleton; |
|---|
| 9 | 9 | import javax.persistence.EntityManager; |
|---|
| 10 | +import javax.transaction.Transactional; |
|---|
| 10 | 11 | |
|---|
| 11 | 12 | import net.curisit.integrity.commons.Utils; |
|---|
| 12 | 13 | import net.curisit.securis.db.User; |
|---|
| 13 | 14 | |
|---|
| 14 | | -@Singleton |
|---|
| 15 | +@ApplicationScoped |
|---|
| 15 | 16 | public class UserDao { |
|---|
| 16 | 17 | |
|---|
| 17 | 18 | @Inject |
|---|
| .. | .. |
|---|
| 21 | 22 | @Inject |
|---|
| 22 | 23 | Provider<EntityManager> emProvider; |
|---|
| 23 | 24 | |
|---|
| 24 | | - @com.google.inject.persist.Transactional |
|---|
| 25 | + @Transactional |
|---|
| 25 | 26 | public User test(String username) { |
|---|
| 26 | 27 | EntityManager em = emProvider.get(); |
|---|
| 27 | 28 | User user = new User(); |
|---|
| .. | .. |
|---|
| 2 | 2 | |
|---|
| 3 | 3 | import java.util.Date; |
|---|
| 4 | 4 | |
|---|
| 5 | | -import javax.inject.Inject; |
|---|
| 6 | | -import javax.inject.Singleton; |
|---|
| 5 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 7 | 6 | import javax.persistence.EntityManager; |
|---|
| 7 | +import javax.persistence.PersistenceContext; |
|---|
| 8 | +import javax.transaction.Transactional; |
|---|
| 8 | 9 | |
|---|
| 9 | 10 | import net.curisit.integrity.commons.Utils; |
|---|
| 10 | 11 | import net.curisit.securis.db.Settings; |
|---|
| .. | .. |
|---|
| 12 | 13 | import org.apache.logging.log4j.LogManager; |
|---|
| 13 | 14 | import org.apache.logging.log4j.Logger; |
|---|
| 14 | 15 | |
|---|
| 15 | | -import com.google.inject.Provider; |
|---|
| 16 | | -import com.google.inject.persist.Transactional; |
|---|
| 17 | | - |
|---|
| 18 | | -@Singleton |
|---|
| 16 | +@ApplicationScoped |
|---|
| 19 | 17 | public class SystemParams { |
|---|
| 20 | 18 | |
|---|
| 21 | 19 | @SuppressWarnings("unused") |
|---|
| 22 | 20 | private static final Logger LOG = LogManager.getLogger(SystemParams.class); |
|---|
| 23 | 21 | |
|---|
| 24 | | - @Inject |
|---|
| 25 | | - private Provider<EntityManager> emp; |
|---|
| 22 | + @PersistenceContext(unitName = "localdb") |
|---|
| 23 | + private EntityManager em; |
|---|
| 26 | 24 | |
|---|
| 27 | 25 | /** |
|---|
| 28 | 26 | * Returns the system parameter value for given key |
|---|
| .. | .. |
|---|
| 111 | 109 | * @return |
|---|
| 112 | 110 | */ |
|---|
| 113 | 111 | public String getParam(String key, String defaultValue) { |
|---|
| 114 | | - EntityManager em = emp.get(); |
|---|
| 115 | 112 | Settings p = em.find(Settings.class, key); |
|---|
| 116 | 113 | return p == null ? defaultValue : p.getValue(); |
|---|
| 117 | 114 | } |
|---|
| .. | .. |
|---|
| 125 | 122 | */ |
|---|
| 126 | 123 | @Transactional |
|---|
| 127 | 124 | public void setParam(String key, String value) { |
|---|
| 128 | | - EntityManager em = this.emp.get(); |
|---|
| 129 | 125 | Settings p = em.find(Settings.class, key); |
|---|
| 130 | 126 | if (p == null) { |
|---|
| 131 | 127 | p = new Settings(); |
|---|
| .. | .. |
|---|
| 187 | 183 | */ |
|---|
| 188 | 184 | @Transactional |
|---|
| 189 | 185 | public void removeParam(String key) { |
|---|
| 190 | | - EntityManager em = this.emp.get(); |
|---|
| 191 | 186 | Settings p = em.find(Settings.class, key); |
|---|
| 192 | 187 | if (p != null) { |
|---|
| 193 | 188 | em.remove(p); |
|---|
| .. | .. |
|---|
| 1 | +package net.curisit.securis.ioc; |
|---|
| 2 | + |
|---|
| 3 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 4 | +import javax.enterprise.inject.Default; |
|---|
| 5 | +import javax.enterprise.inject.Disposes; |
|---|
| 6 | +import javax.enterprise.inject.Produces; |
|---|
| 7 | +import javax.inject.Inject; |
|---|
| 8 | +import javax.persistence.EntityManager; |
|---|
| 9 | +import javax.persistence.EntityManagerFactory; |
|---|
| 10 | + |
|---|
| 11 | +import org.apache.logging.log4j.LogManager; |
|---|
| 12 | +import org.apache.logging.log4j.Logger; |
|---|
| 13 | + |
|---|
| 14 | +@ApplicationScoped |
|---|
| 15 | +public class DatabaseProvider { |
|---|
| 16 | + |
|---|
| 17 | + private static final Logger LOG = LogManager.getLogger(DatabaseProvider.class); |
|---|
| 18 | + |
|---|
| 19 | + @Inject |
|---|
| 20 | + public DatabaseProvider() { |
|---|
| 21 | + LOG.info("Contructor DatabaseProvider, emf: {}, em: {} ", entityManagerFactory, getEM()); |
|---|
| 22 | + } |
|---|
| 23 | + |
|---|
| 24 | + private EntityManagerFactory entityManagerFactory = javax.persistence.Persistence.createEntityManagerFactory("localdb"); |
|---|
| 25 | + |
|---|
| 26 | + // EntityManagerFactory emfH2 = |
|---|
| 27 | + // javax.persistence.Persistence.createEntityManagerFactory("localdb"); |
|---|
| 28 | + @Produces |
|---|
| 29 | + private EntityManager getEM() { |
|---|
| 30 | + return entityManagerFactory.createEntityManager(); |
|---|
| 31 | + } |
|---|
| 32 | + |
|---|
| 33 | + public void dispose(@Disposes @Default EntityManager entityManager) { |
|---|
| 34 | + if (entityManager.isOpen()) { |
|---|
| 35 | + entityManager.close(); |
|---|
| 36 | + } |
|---|
| 37 | + } |
|---|
| 38 | +} |
|---|
| .. | .. |
|---|
| 1 | +package net.curisit.securis.ioc; |
|---|
| 2 | + |
|---|
| 3 | +import java.lang.annotation.ElementType; |
|---|
| 4 | +import java.lang.annotation.Retention; |
|---|
| 5 | +import java.lang.annotation.RetentionPolicy; |
|---|
| 6 | +import java.lang.annotation.Target; |
|---|
| 7 | + |
|---|
| 8 | +import javax.interceptor.InterceptorBinding; |
|---|
| 9 | + |
|---|
| 10 | +@Target({ |
|---|
| 11 | + ElementType.METHOD, ElementType.TYPE |
|---|
| 12 | +}) |
|---|
| 13 | +@Retention(RetentionPolicy.RUNTIME) |
|---|
| 14 | +@InterceptorBinding |
|---|
| 15 | +public @interface MyTrans { |
|---|
| 16 | + |
|---|
| 17 | +} |
|---|
| .. | .. |
|---|
| 5 | 5 | import net.curisit.securis.services.ApplicationResource; |
|---|
| 6 | 6 | import net.curisit.securis.services.BasicServices; |
|---|
| 7 | 7 | import net.curisit.securis.services.LicenseResource; |
|---|
| 8 | | -import net.curisit.securis.services.LicenseServices; |
|---|
| 9 | 8 | import net.curisit.securis.services.LicenseTypeResource; |
|---|
| 10 | 9 | import net.curisit.securis.services.OrganizationResource; |
|---|
| 11 | 10 | import net.curisit.securis.services.PackResource; |
|---|
| 12 | 11 | import net.curisit.securis.services.UserResource; |
|---|
| 13 | 12 | |
|---|
| 14 | | -import org.jboss.resteasy.plugins.guice.ext.RequestScopeModule; |
|---|
| 13 | +import com.google.inject.AbstractModule; |
|---|
| 15 | 14 | |
|---|
| 16 | | -public class RequestsModule extends RequestScopeModule { |
|---|
| 15 | +public class RequestsModule extends AbstractModule { |
|---|
| 17 | 16 | |
|---|
| 18 | 17 | @Override |
|---|
| 19 | 18 | protected void configure() { |
|---|
| 20 | | - super.configure(); |
|---|
| 21 | 19 | // TODO: Make the bind using reflection dynamically |
|---|
| 22 | 20 | bind(SecurityInterceptor.class); |
|---|
| 23 | 21 | |
|---|
| 24 | 22 | bind(BasicServices.class); |
|---|
| 25 | | - bind(LicenseServices.class); |
|---|
| 26 | 23 | bind(UserResource.class); |
|---|
| 27 | 24 | |
|---|
| 28 | 25 | bind(ApplicationResource.class); |
|---|
| .. | .. |
|---|
| 31 | 28 | bind(ApiResource.class); |
|---|
| 32 | 29 | bind(LicenseResource.class); |
|---|
| 33 | 30 | bind(PackResource.class); |
|---|
| 31 | + |
|---|
| 34 | 32 | } |
|---|
| 33 | + |
|---|
| 35 | 34 | // @Provides |
|---|
| 36 | 35 | // @RequestScoped |
|---|
| 37 | 36 | // public User provideUser() { |
|---|
| .. | .. |
|---|
| 7 | 7 | import java.util.List; |
|---|
| 8 | 8 | import java.util.Properties; |
|---|
| 9 | 9 | |
|---|
| 10 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 10 | 11 | import javax.inject.Named; |
|---|
| 11 | | -import javax.inject.Singleton; |
|---|
| 12 | | -import javax.sql.DataSource; |
|---|
| 13 | 12 | import javax.ws.rs.core.UriBuilder; |
|---|
| 14 | 13 | import javax.ws.rs.core.UriBuilderException; |
|---|
| 15 | 14 | |
|---|
| 16 | 15 | import org.apache.logging.log4j.LogManager; |
|---|
| 17 | 16 | import org.apache.logging.log4j.Logger; |
|---|
| 18 | | -import org.h2.jdbcx.JdbcDataSource; |
|---|
| 19 | 17 | |
|---|
| 20 | 18 | import com.google.inject.AbstractModule; |
|---|
| 21 | 19 | import com.google.inject.Provides; |
|---|
| .. | .. |
|---|
| 46 | 44 | |
|---|
| 47 | 45 | @Named("base-uri") |
|---|
| 48 | 46 | @Provides |
|---|
| 49 | | - @Singleton |
|---|
| 47 | + @ApplicationScoped |
|---|
| 50 | 48 | public URI getBaseURI() { |
|---|
| 51 | 49 | // TODO Read from configuration, where? |
|---|
| 52 | 50 | try { |
|---|
| .. | .. |
|---|
| 81 | 79 | |
|---|
| 82 | 80 | @Named("temporary-dir") |
|---|
| 83 | 81 | @Provides |
|---|
| 84 | | - @Singleton |
|---|
| 82 | + @ApplicationScoped |
|---|
| 85 | 83 | public File getTemporaryDir() { |
|---|
| 86 | 84 | String tmp = getAppDir().getAbsolutePath(); |
|---|
| 87 | 85 | tmp += File.separator + ".TEMP"; |
|---|
| .. | .. |
|---|
| 98 | 96 | |
|---|
| 99 | 97 | @Named("app-dir") |
|---|
| 100 | 98 | @Provides |
|---|
| 101 | | - @Singleton |
|---|
| 99 | + @ApplicationScoped |
|---|
| 102 | 100 | public File getAppDir() { |
|---|
| 103 | 101 | String appDir = System.getProperty("user.home", System.getProperty("user.dir")); |
|---|
| 104 | 102 | if (appDir == null) { |
|---|
| .. | .. |
|---|
| 117 | 115 | |
|---|
| 118 | 116 | @Named("support-email") |
|---|
| 119 | 117 | @Provides |
|---|
| 120 | | - @Singleton |
|---|
| 118 | + @ApplicationScoped |
|---|
| 121 | 119 | public String getSupportEmail() { |
|---|
| 122 | | - return "integrity@curistec.com"; |
|---|
| 120 | + return "support@curisit.net"; |
|---|
| 123 | 121 | } |
|---|
| 124 | 122 | |
|---|
| 125 | 123 | @Named("hash-logo") |
|---|
| 126 | 124 | @Provides |
|---|
| 127 | | - @Singleton |
|---|
| 125 | + @ApplicationScoped |
|---|
| 128 | 126 | public String getHashLogo() { |
|---|
| 129 | 127 | return "1b42616809d4cd8ccf109e3c30d0ab25067f160b30b7354a08ddd563de0096ba"; |
|---|
| 130 | 128 | } |
|---|
| 131 | 129 | |
|---|
| 132 | | - @Provides |
|---|
| 133 | | - @Singleton |
|---|
| 134 | | - public DataSource getDataSource(@Named("app-dir") File appDir) { |
|---|
| 135 | | - |
|---|
| 136 | | - JdbcDataSource dataSource = new JdbcDataSource(); |
|---|
| 137 | | - dataSource.setURL(getUrl(appDir)); |
|---|
| 138 | | - dataSource.setUser("curis"); |
|---|
| 139 | | - dataSource.setPassword(getPassword()); |
|---|
| 140 | | - LOG.debug("JdbcDataSource: {}", dataSource); |
|---|
| 141 | | - return dataSource; |
|---|
| 142 | | - } |
|---|
| 143 | | - |
|---|
| 144 | 130 | @Named("db-files") |
|---|
| 145 | 131 | @Provides |
|---|
| 146 | | - @Singleton |
|---|
| 132 | + @ApplicationScoped |
|---|
| 147 | 133 | public List<String> getDbFiles() { |
|---|
| 148 | 134 | return getAppDbFiles(); |
|---|
| 149 | 135 | } |
|---|
| .. | .. |
|---|
| 1 | +package net.curisit.securis.ioc; |
|---|
| 2 | + |
|---|
| 3 | +import java.io.IOException; |
|---|
| 4 | +import java.lang.reflect.Method; |
|---|
| 5 | + |
|---|
| 6 | +import javax.inject.Inject; |
|---|
| 7 | +import javax.interceptor.AroundInvoke; |
|---|
| 8 | +import javax.interceptor.Interceptor; |
|---|
| 9 | +import javax.interceptor.InvocationContext; |
|---|
| 10 | +import javax.persistence.EntityManager; |
|---|
| 11 | +import javax.ws.rs.container.ContainerRequestContext; |
|---|
| 12 | +import javax.ws.rs.container.ContainerResponseContext; |
|---|
| 13 | +import javax.ws.rs.core.Response.Status; |
|---|
| 14 | + |
|---|
| 15 | +import org.apache.logging.log4j.LogManager; |
|---|
| 16 | +import org.apache.logging.log4j.Logger; |
|---|
| 17 | +import org.jboss.resteasy.core.ResourceMethodInvoker; |
|---|
| 18 | +import org.jboss.resteasy.spi.ResteasyProviderFactory; |
|---|
| 19 | + |
|---|
| 20 | +import com.google.inject.persist.Transactional; |
|---|
| 21 | + |
|---|
| 22 | +@Interceptor |
|---|
| 23 | +@MyTrans |
|---|
| 24 | +public class TransactionsManager { |
|---|
| 25 | + |
|---|
| 26 | + private static final Logger LOG = LogManager.getLogger(TransactionsManager.class); |
|---|
| 27 | + |
|---|
| 28 | + @Inject |
|---|
| 29 | + private EntityManager em; |
|---|
| 30 | + |
|---|
| 31 | + // @Inject |
|---|
| 32 | + // private ThreadLocal<EntityManager> threadLocal; |
|---|
| 33 | + |
|---|
| 34 | + @AroundInvoke |
|---|
| 35 | + public Object invoke(InvocationContext context) throws Exception { |
|---|
| 36 | + // EntityTransaction trx = manager.getTransaction(); |
|---|
| 37 | + if (!em.getTransaction().isActive()) { |
|---|
| 38 | + em.getTransaction().begin(); |
|---|
| 39 | + LOG.info("INIT trans"); |
|---|
| 40 | + ResteasyProviderFactory.pushContext(EntityManager.class, em); |
|---|
| 41 | + Object result = context.proceed(); |
|---|
| 42 | + |
|---|
| 43 | + em.getTransaction().commit(); |
|---|
| 44 | + LOG.info("COMMIT trans"); |
|---|
| 45 | + return result; |
|---|
| 46 | + } |
|---|
| 47 | + LOG.info("No trans"); |
|---|
| 48 | + Object result = context.proceed(); |
|---|
| 49 | + return result; |
|---|
| 50 | + } |
|---|
| 51 | + |
|---|
| 52 | + public void filter(ContainerRequestContext requestContext) throws IOException { |
|---|
| 53 | + ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker) requestContext.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker"); |
|---|
| 54 | + Method method = methodInvoker.getMethod(); |
|---|
| 55 | + |
|---|
| 56 | + if (method.isAnnotationPresent(Transactional.class)) { |
|---|
| 57 | + LOG.info("WE need transaction!!!"); |
|---|
| 58 | + em.getTransaction().begin(); |
|---|
| 59 | + } |
|---|
| 60 | + } |
|---|
| 61 | + |
|---|
| 62 | + public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { |
|---|
| 63 | + // TODO Auto-generated method stub |
|---|
| 64 | + |
|---|
| 65 | + if (em.getTransaction().isActive()) { |
|---|
| 66 | + LOG.info("There is transaction go ahead..."); |
|---|
| 67 | + if (responseContext.getStatus() == Status.OK.getStatusCode()) { |
|---|
| 68 | + em.getTransaction().commit(); |
|---|
| 69 | + LOG.info("COMMIT"); |
|---|
| 70 | + } else { |
|---|
| 71 | + em.getTransaction().rollback(); |
|---|
| 72 | + LOG.info("ROLLBACK"); |
|---|
| 73 | + } |
|---|
| 74 | + } else { |
|---|
| 75 | + LOG.info("There is NO transaction"); |
|---|
| 76 | + |
|---|
| 77 | + } |
|---|
| 78 | + } |
|---|
| 79 | + |
|---|
| 80 | +} |
|---|
| .. | .. |
|---|
| 31 | 31 | import org.jboss.resteasy.spi.ResteasyProviderFactory; |
|---|
| 32 | 32 | |
|---|
| 33 | 33 | @Provider |
|---|
| 34 | | -// @PreMatching |
|---|
| 35 | 34 | @Priority(Priorities.AUTHENTICATION) |
|---|
| 36 | 35 | public class SecurityInterceptor implements javax.ws.rs.container.ContainerRequestFilter { |
|---|
| 37 | 36 | private static final Logger LOG = LogManager.getLogger(SecurityInterceptor.class); |
|---|
| 38 | | - |
|---|
| 39 | | - @Inject |
|---|
| 40 | | - private TokenHelper tokenHelper; |
|---|
| 41 | 37 | |
|---|
| 42 | 38 | @Context |
|---|
| 43 | 39 | private HttpServletRequest servletRequest; |
|---|
| 44 | 40 | |
|---|
| 45 | 41 | @Inject |
|---|
| 46 | | - CacheTTL cache; |
|---|
| 47 | | - |
|---|
| 48 | | - @Context |
|---|
| 49 | | - Dispatcher dispatcher; |
|---|
| 42 | + private CacheTTL cache; |
|---|
| 50 | 43 | |
|---|
| 51 | 44 | @Inject |
|---|
| 52 | | - com.google.inject.Provider<EntityManager> emProvider; |
|---|
| 45 | + private TokenHelper tokenHelper; |
|---|
| 46 | + |
|---|
| 47 | + @Context |
|---|
| 48 | + private Dispatcher dispatcher; |
|---|
| 49 | + |
|---|
| 50 | + @Inject |
|---|
| 51 | + private EntityManager em; |
|---|
| 53 | 52 | |
|---|
| 54 | 53 | public void filter(ContainerRequestContext containerRequestContext) throws IOException { |
|---|
| 54 | + |
|---|
| 55 | 55 | ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker) containerRequestContext |
|---|
| 56 | 56 | .getProperty("org.jboss.resteasy.core.ResourceMethodInvoker"); |
|---|
| 57 | 57 | Method method = methodInvoker.getMethod(); |
|---|
| .. | .. |
|---|
| 76 | 76 | containerRequestContext.setSecurityContext(scw); |
|---|
| 77 | 77 | // Next line provide injection in resource methods |
|---|
| 78 | 78 | ResteasyProviderFactory.pushContext(BasicSecurityContext.class, scw); |
|---|
| 79 | + ResteasyProviderFactory.pushContext(EntityManager.class, em); |
|---|
| 79 | 80 | LOG.debug("Added custom SecurityContext for user {}, orgs: {}", username, orgs); |
|---|
| 80 | 81 | } |
|---|
| 81 | 82 | } |
|---|
| .. | .. |
|---|
| 85 | 86 | Set<Integer> userOrgs = cache.get("orgs_" + username, Set.class); |
|---|
| 86 | 87 | if (userOrgs == null) { |
|---|
| 87 | 88 | // Theorically this shouldn't be never null, but just in case... |
|---|
| 88 | | - EntityManager em = emProvider.get(); |
|---|
| 89 | 89 | User user = em.find(User.class, username); |
|---|
| 90 | 90 | if (user != null) { |
|---|
| 91 | 91 | userOrgs = user.getAllOrgsIds(); |
|---|
| .. | .. |
|---|
| 103 | 103 | } |
|---|
| 104 | 104 | Integer userRoles = cache.get("roles_" + username, Integer.class); |
|---|
| 105 | 105 | if (userRoles == null) { |
|---|
| 106 | | - EntityManager em = emProvider.get(); |
|---|
| 107 | 106 | User user = em.find(User.class, username); |
|---|
| 108 | 107 | if (user != null) { |
|---|
| 109 | 108 | userRoles = 0; |
|---|
| .. | .. |
|---|
| 5 | 5 | import java.util.List; |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | import javax.inject.Inject; |
|---|
| 8 | | -import javax.inject.Provider; |
|---|
| 9 | 8 | import javax.persistence.EntityManager; |
|---|
| 9 | +import javax.transaction.Transactional; |
|---|
| 10 | 10 | import javax.ws.rs.Consumes; |
|---|
| 11 | 11 | import javax.ws.rs.GET; |
|---|
| 12 | 12 | import javax.ws.rs.HeaderParam; |
|---|
| .. | .. |
|---|
| 45 | 45 | import org.apache.logging.log4j.Logger; |
|---|
| 46 | 46 | import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; |
|---|
| 47 | 47 | |
|---|
| 48 | | -import com.google.inject.persist.Transactional; |
|---|
| 49 | | - |
|---|
| 50 | 48 | /** |
|---|
| 51 | 49 | * External API to be accessed by third parties |
|---|
| 52 | 50 | * |
|---|
| .. | .. |
|---|
| 64 | 62 | private LicenseHelper licenseHelper; |
|---|
| 65 | 63 | |
|---|
| 66 | 64 | @Inject |
|---|
| 67 | | - Provider<EntityManager> emProvider; |
|---|
| 65 | + EntityManager em; |
|---|
| 68 | 66 | |
|---|
| 69 | 67 | @Inject |
|---|
| 70 | 68 | LicenseGenerator licenseGenerator; |
|---|
| .. | .. |
|---|
| 124 | 122 | public Response createFromRequest(RequestBean request, @HeaderParam(LicenseManager.HEADER_LICENSE_NAME_OR_REFERENCE) String nameOrReference, |
|---|
| 125 | 123 | @HeaderParam(LicenseManager.HEADER_LICENSE_EMAIL) String userEmail) throws IOException, SeCurisServiceException, SeCurisException { |
|---|
| 126 | 124 | LOG.info("Request to get license: {}", request); |
|---|
| 127 | | - SignedLicenseBean lic = createLicense(request, emProvider.get(), false, nameOrReference, userEmail); |
|---|
| 125 | + SignedLicenseBean lic = createLicense(request, em, false, nameOrReference, userEmail); |
|---|
| 128 | 126 | |
|---|
| 129 | 127 | return Response.ok(lic).build(); |
|---|
| 130 | 128 | } |
|---|
| .. | .. |
|---|
| 189 | 187 | throw new SeCurisServiceException(ErrorCodes.LICENSE_NOT_READY_FOR_RENEW, "The license is still valid, not ready for renew"); |
|---|
| 190 | 188 | } |
|---|
| 191 | 189 | |
|---|
| 192 | | - EntityManager em = emProvider.get(); |
|---|
| 190 | + // EntityManager em = emProvider.get(); |
|---|
| 193 | 191 | License lic = License.findLicenseByCode(previousLic.getLicenseCode(), em); |
|---|
| 194 | 192 | if (lic.getStatus() != LicenseStatus.ACTIVE) { |
|---|
| 195 | 193 | throw new SeCurisServiceException(ErrorCodes.LICENSE_NOT_READY_FOR_RENEW, "Only licenses with status 'Active' can be renew"); |
|---|
| .. | .. |
|---|
| 226 | 224 | throw new SeCurisServiceException(ErrorCodes.LICENSE_IS_EXPIRED, "The license is expired"); |
|---|
| 227 | 225 | } |
|---|
| 228 | 226 | |
|---|
| 229 | | - EntityManager em = emProvider.get(); |
|---|
| 227 | + // EntityManager em = emProvider.get(); |
|---|
| 230 | 228 | try { |
|---|
| 231 | 229 | SignatureHelper.getInstance().validateSignature(currentLic); |
|---|
| 232 | 230 | } catch (SeCurisException ex) { |
|---|
| .. | .. |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | import javax.annotation.security.RolesAllowed; |
|---|
| 8 | 8 | import javax.inject.Inject; |
|---|
| 9 | | -import javax.inject.Provider; |
|---|
| 10 | 9 | import javax.persistence.EntityManager; |
|---|
| 11 | 10 | import javax.persistence.TypedQuery; |
|---|
| 12 | 11 | import javax.servlet.http.HttpServletRequest; |
|---|
| 12 | +import javax.transaction.Transactional; |
|---|
| 13 | 13 | import javax.ws.rs.Consumes; |
|---|
| 14 | 14 | import javax.ws.rs.DELETE; |
|---|
| 15 | 15 | import javax.ws.rs.GET; |
|---|
| .. | .. |
|---|
| 39 | 39 | import org.apache.logging.log4j.LogManager; |
|---|
| 40 | 40 | import org.apache.logging.log4j.Logger; |
|---|
| 41 | 41 | |
|---|
| 42 | | -import com.google.inject.persist.Transactional; |
|---|
| 43 | | - |
|---|
| 44 | 42 | /** |
|---|
| 45 | 43 | * Application resource, this service will provide methods to create, modify and |
|---|
| 46 | 44 | * delete applications |
|---|
| .. | .. |
|---|
| 54 | 52 | TokenHelper tokenHelper; |
|---|
| 55 | 53 | |
|---|
| 56 | 54 | @Inject |
|---|
| 57 | | - Provider<EntityManager> emProvider; |
|---|
| 55 | + EntityManager em; |
|---|
| 58 | 56 | |
|---|
| 59 | 57 | private static final Logger LOG = LogManager.getLogger(ApplicationResource.class); |
|---|
| 60 | 58 | |
|---|
| .. | .. |
|---|
| 74 | 72 | public Response index() { |
|---|
| 75 | 73 | LOG.info("Getting applications list "); |
|---|
| 76 | 74 | |
|---|
| 77 | | - EntityManager em = emProvider.get(); |
|---|
| 75 | + // EntityManager em = emProvider.get(); |
|---|
| 78 | 76 | em.clear(); |
|---|
| 79 | 77 | TypedQuery<Application> q = em.createNamedQuery("list-applications", Application.class); |
|---|
| 80 | 78 | List<Application> list = q.getResultList(); |
|---|
| .. | .. |
|---|
| 100 | 98 | return Response.status(Status.NOT_FOUND).build(); |
|---|
| 101 | 99 | } |
|---|
| 102 | 100 | |
|---|
| 103 | | - EntityManager em = emProvider.get(); |
|---|
| 101 | + // EntityManager em = emProvider.get(); |
|---|
| 104 | 102 | em.clear(); |
|---|
| 105 | 103 | |
|---|
| 106 | 104 | Application app = null; |
|---|
| .. | .. |
|---|
| 138 | 136 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 139 | 137 | public Response create(Application app, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 140 | 138 | LOG.info("Creating new application"); |
|---|
| 141 | | - EntityManager em = emProvider.get(); |
|---|
| 139 | + // EntityManager em = emProvider.get(); |
|---|
| 142 | 140 | app.setCreationTimestamp(new Date()); |
|---|
| 143 | 141 | em.persist(app); |
|---|
| 144 | 142 | LOG.info("App ID: {}", app.getId()); |
|---|
| .. | .. |
|---|
| 167 | 165 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 168 | 166 | public Response modify(Application app, @PathParam("appid") String appid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 169 | 167 | LOG.info("Modifying application with id: {}", appid); |
|---|
| 170 | | - EntityManager em = emProvider.get(); |
|---|
| 168 | + // EntityManager em = emProvider.get(); |
|---|
| 171 | 169 | Application currentapp = em.find(Application.class, Integer.parseInt(appid)); |
|---|
| 172 | 170 | if (currentapp == null) { |
|---|
| 173 | 171 | LOG.error("Application with id {} not found in DB", appid); |
|---|
| .. | .. |
|---|
| 214 | 212 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 215 | 213 | public Response delete(@PathParam("appid") String appid, @Context HttpServletRequest request) { |
|---|
| 216 | 214 | LOG.info("Deleting app with id: {}", appid); |
|---|
| 217 | | - EntityManager em = emProvider.get(); |
|---|
| 215 | + // EntityManager em = emProvider.get(); |
|---|
| 218 | 216 | Application app = em.find(Application.class, Integer.parseInt(appid)); |
|---|
| 219 | 217 | if (app == null) { |
|---|
| 220 | 218 | LOG.error("Application with id {} can not be deleted, It was not found in DB", appid); |
|---|
| .. | .. |
|---|
| 3 | 3 | import java.net.URI; |
|---|
| 4 | 4 | import java.util.Date; |
|---|
| 5 | 5 | |
|---|
| 6 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 6 | 7 | import javax.inject.Inject; |
|---|
| 7 | | -import javax.inject.Singleton; |
|---|
| 8 | 8 | import javax.servlet.http.HttpServletRequest; |
|---|
| 9 | +import javax.transaction.Transactional; |
|---|
| 9 | 10 | import javax.ws.rs.FormParam; |
|---|
| 10 | 11 | import javax.ws.rs.GET; |
|---|
| 11 | 12 | import javax.ws.rs.HeaderParam; |
|---|
| .. | .. |
|---|
| 27 | 28 | import org.apache.logging.log4j.LogManager; |
|---|
| 28 | 29 | import org.apache.logging.log4j.Logger; |
|---|
| 29 | 30 | |
|---|
| 30 | | -import com.google.inject.persist.Transactional; |
|---|
| 31 | | - |
|---|
| 32 | 31 | /** |
|---|
| 33 | 32 | * Basic services for login and basic app wrkflow |
|---|
| 34 | 33 | * |
|---|
| 35 | 34 | * @author roberto <roberto.sanchez@curisit.net> |
|---|
| 36 | 35 | */ |
|---|
| 37 | 36 | @Path("/") |
|---|
| 38 | | -@Singleton |
|---|
| 37 | +@ApplicationScoped |
|---|
| 39 | 38 | public class BasicServices { |
|---|
| 40 | 39 | |
|---|
| 41 | 40 | private static final Logger LOG = LogManager.getLogger(BasicServices.class); |
|---|
| .. | .. |
|---|
| 7 | 7 | import java.util.List; |
|---|
| 8 | 8 | |
|---|
| 9 | 9 | import javax.inject.Inject; |
|---|
| 10 | | -import javax.inject.Provider; |
|---|
| 11 | 10 | import javax.persistence.EntityManager; |
|---|
| 12 | | -import javax.persistence.PersistenceContext; |
|---|
| 13 | | -import javax.persistence.SynchronizationType; |
|---|
| 14 | 11 | import javax.persistence.TypedQuery; |
|---|
| 12 | +import javax.transaction.Transactional; |
|---|
| 15 | 13 | import javax.ws.rs.Consumes; |
|---|
| 16 | 14 | import javax.ws.rs.DELETE; |
|---|
| 17 | 15 | import javax.ws.rs.DefaultValue; |
|---|
| .. | .. |
|---|
| 62 | 60 | import com.fasterxml.jackson.annotation.JsonAutoDetect; |
|---|
| 63 | 61 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|---|
| 64 | 62 | import com.fasterxml.jackson.annotation.JsonProperty; |
|---|
| 65 | | -import com.google.inject.persist.Transactional; |
|---|
| 66 | 63 | |
|---|
| 67 | 64 | /** |
|---|
| 68 | 65 | * License resource, this service will provide methods to create, modify and |
|---|
| .. | .. |
|---|
| 85 | 82 | private LicenseHelper licenseHelper; |
|---|
| 86 | 83 | |
|---|
| 87 | 84 | @Inject |
|---|
| 88 | | - private Provider<EntityManager> emProvider; |
|---|
| 89 | | - |
|---|
| 90 | | - @PersistenceContext(unitName = "localdb", synchronization = SynchronizationType.SYNCHRONIZED) |
|---|
| 91 | | - private EntityManager entityManager; |
|---|
| 85 | + EntityManager em; |
|---|
| 92 | 86 | |
|---|
| 93 | 87 | @Inject |
|---|
| 94 | 88 | private LicenseGenerator licenseGenerator; |
|---|
| .. | .. |
|---|
| 106 | 100 | public Response index(@QueryParam("packId") Integer packId, @Context BasicSecurityContext bsc) { |
|---|
| 107 | 101 | LOG.info("Getting licenses list "); |
|---|
| 108 | 102 | |
|---|
| 109 | | - EntityManager em = emProvider.get(); |
|---|
| 103 | + // EntityManager em = emProvider.get(); |
|---|
| 110 | 104 | em.clear(); |
|---|
| 111 | 105 | |
|---|
| 112 | 106 | if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) { |
|---|
| .. | .. |
|---|
| 141 | 135 | public Response get(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 142 | 136 | LOG.info("Getting organization data for id: {}: ", licId); |
|---|
| 143 | 137 | |
|---|
| 144 | | - EntityManager em = emProvider.get(); |
|---|
| 138 | + // EntityManager em = emProvider.get(); |
|---|
| 145 | 139 | em.clear(); |
|---|
| 146 | 140 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 147 | 141 | return Response.ok(lic).build(); |
|---|
| .. | .. |
|---|
| 161 | 155 | @Transactional |
|---|
| 162 | 156 | public Response download(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 163 | 157 | |
|---|
| 164 | | - EntityManager em = emProvider.get(); |
|---|
| 158 | + // EntityManager em = emProvider.get(); |
|---|
| 165 | 159 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 166 | 160 | |
|---|
| 167 | 161 | if (lic.getLicenseData() == null) { |
|---|
| .. | .. |
|---|
| 198 | 192 | }) |
|---|
| 199 | 193 | public Response activate(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 200 | 194 | |
|---|
| 201 | | - EntityManager em = emProvider.get(); |
|---|
| 195 | + // EntityManager em = emProvider.get(); |
|---|
| 202 | 196 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 203 | 197 | |
|---|
| 204 | 198 | if (!License.Status.isActionValid(License.Action.ACTIVATION, lic.getStatus())) { |
|---|
| .. | .. |
|---|
| 247 | 241 | public Response send(@PathParam("licId") Integer licId, @DefaultValue("false") @FormParam("add_cc") Boolean addCC, |
|---|
| 248 | 242 | @Context BasicSecurityContext bsc) throws SeCurisServiceException, SeCurisException { |
|---|
| 249 | 243 | |
|---|
| 250 | | - EntityManager em = emProvider.get(); |
|---|
| 244 | + // EntityManager em = emProvider.get(); |
|---|
| 251 | 245 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 252 | 246 | Application app = lic.getPack().getLicenseType().getApplication(); |
|---|
| 253 | 247 | File licFile = null; |
|---|
| .. | .. |
|---|
| 303 | 297 | public Response cancel(@PathParam("licId") Integer licId, CancellationLicenseActionBean actionData, @Context BasicSecurityContext bsc) |
|---|
| 304 | 298 | throws SeCurisServiceException { |
|---|
| 305 | 299 | |
|---|
| 306 | | - EntityManager em = emProvider.get(); |
|---|
| 300 | + // EntityManager em = emProvider.get(); |
|---|
| 307 | 301 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 308 | 302 | |
|---|
| 309 | 303 | if (!License.Status.isActionValid(License.Action.CANCEL, lic.getStatus())) { |
|---|
| .. | .. |
|---|
| 348 | 342 | }) |
|---|
| 349 | 343 | @Transactional |
|---|
| 350 | 344 | public Response create(License lic, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 351 | | - EntityManager em = emProvider.get(); |
|---|
| 345 | + // EntityManager em = emProvider.get(); |
|---|
| 352 | 346 | |
|---|
| 353 | 347 | if (checkIfCodeExists(lic.getCode(), em)) { |
|---|
| 354 | 348 | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The license code is already used in an existing license"); |
|---|
| .. | .. |
|---|
| 476 | 470 | public Response modify(License lic, @PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 477 | 471 | LOG.info("Modifying organization with id: {}", licId); |
|---|
| 478 | 472 | |
|---|
| 479 | | - EntityManager em = emProvider.get(); |
|---|
| 473 | + // EntityManager em = emProvider.get(); |
|---|
| 480 | 474 | |
|---|
| 481 | 475 | License currentLicense = getCurrentLicense(licId, bsc, em); |
|---|
| 482 | 476 | currentLicense.setComments(lic.getComments()); |
|---|
| .. | .. |
|---|
| 522 | 516 | }) |
|---|
| 523 | 517 | public Response delete(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 524 | 518 | LOG.info("Deleting license with id: {}", licId); |
|---|
| 525 | | - EntityManager em = emProvider.get(); |
|---|
| 519 | + // EntityManager em = emProvider.get(); |
|---|
| 526 | 520 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 527 | 521 | |
|---|
| 528 | 522 | if (!License.Status.isActionValid(License.Action.DELETE, lic.getStatus())) { |
|---|
| .. | .. |
|---|
| 554 | 548 | }) |
|---|
| 555 | 549 | public Response block(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 556 | 550 | LOG.info("Blocking license with id: {}", licId); |
|---|
| 557 | | - EntityManager em = emProvider.get(); |
|---|
| 551 | + // EntityManager em = emProvider.get(); |
|---|
| 558 | 552 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 559 | 553 | |
|---|
| 560 | 554 | if (!License.Status.isActionValid(License.Action.BLOCK, lic.getStatus())) { |
|---|
| .. | .. |
|---|
| 587 | 581 | }) |
|---|
| 588 | 582 | public Response unblock(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 589 | 583 | LOG.info("Unblocking license with id: {}", licId); |
|---|
| 590 | | - EntityManager em = emProvider.get(); |
|---|
| 584 | + // EntityManager em = emProvider.get(); |
|---|
| 591 | 585 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 592 | 586 | |
|---|
| 593 | 587 | if (BlockedRequest.isRequestBlocked(lic.getRequestData(), em)) { |
|---|
deleted file mode 100644| .. | .. |
|---|
| 1 | | -package net.curisit.securis.services; |
|---|
| 2 | | - |
|---|
| 3 | | -import java.io.IOException; |
|---|
| 4 | | -import java.net.URI; |
|---|
| 5 | | -import java.text.MessageFormat; |
|---|
| 6 | | - |
|---|
| 7 | | -import javax.inject.Named; |
|---|
| 8 | | -import javax.servlet.http.HttpServletRequest; |
|---|
| 9 | | -import javax.ws.rs.Consumes; |
|---|
| 10 | | -import javax.ws.rs.FormParam; |
|---|
| 11 | | -import javax.ws.rs.GET; |
|---|
| 12 | | -import javax.ws.rs.POST; |
|---|
| 13 | | -import javax.ws.rs.Path; |
|---|
| 14 | | -import javax.ws.rs.Produces; |
|---|
| 15 | | -import javax.ws.rs.core.Context; |
|---|
| 16 | | -import javax.ws.rs.core.MediaType; |
|---|
| 17 | | -import javax.ws.rs.core.Response; |
|---|
| 18 | | - |
|---|
| 19 | | -import org.apache.commons.io.IOUtils; |
|---|
| 20 | | -import org.apache.logging.log4j.LogManager; |
|---|
| 21 | | -import org.apache.logging.log4j.Logger; |
|---|
| 22 | | -import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; |
|---|
| 23 | | -import org.jboss.resteasy.annotations.providers.multipart.PartType; |
|---|
| 24 | | - |
|---|
| 25 | | -// The Java class will be hosted at the URI path "/myresource" |
|---|
| 26 | | -@Path("/test") |
|---|
| 27 | | -public class LicenseServices { |
|---|
| 28 | | - |
|---|
| 29 | | - private static final Logger LOG = LogManager.getLogger(LicenseServices.class); |
|---|
| 30 | | - |
|---|
| 31 | | - private static final int DEFAULT_LICENSE_EXPIRATION = 365; |
|---|
| 32 | | - private static final String LICENSE_STRING = "CurisIntegrity Config Server v{0}.{1}"; |
|---|
| 33 | | - |
|---|
| 34 | | - @com.google.inject.Inject |
|---|
| 35 | | - @Named("base-uri") |
|---|
| 36 | | - private URI uri; |
|---|
| 37 | | - |
|---|
| 38 | | - public LicenseServices() { |
|---|
| 39 | | - |
|---|
| 40 | | - } |
|---|
| 41 | | - |
|---|
| 42 | | - /** |
|---|
| 43 | | - * |
|---|
| 44 | | - * @return the server version in format majorVersion.minorVersion |
|---|
| 45 | | - */ |
|---|
| 46 | | - @GET |
|---|
| 47 | | - @Produces({ |
|---|
| 48 | | - MediaType.TEXT_HTML |
|---|
| 49 | | - }) |
|---|
| 50 | | - public Response index() { |
|---|
| 51 | | - try { |
|---|
| 52 | | - String index = IOUtils.toString(this.getClass().getResourceAsStream("/static/index.html")); |
|---|
| 53 | | - return Response.ok().entity(index).build(); |
|---|
| 54 | | - } catch (IOException e) { |
|---|
| 55 | | - LOG.error("Error getting index.html", e); |
|---|
| 56 | | - } |
|---|
| 57 | | - return Response.ok().entity(MessageFormat.format(LICENSE_STRING, 0, 1)).build(); |
|---|
| 58 | | - } |
|---|
| 59 | | - |
|---|
| 60 | | - @GET |
|---|
| 61 | | - @Path("/dummy") |
|---|
| 62 | | - @Produces({ |
|---|
| 63 | | - MediaType.TEXT_PLAIN |
|---|
| 64 | | - }) |
|---|
| 65 | | - public Response dummy(@Context HttpServletRequest request) { |
|---|
| 66 | | - LOG.info("Request: " + request.getPathInfo()); |
|---|
| 67 | | - return Response.ok().entity((uri == null)).build(); |
|---|
| 68 | | - } |
|---|
| 69 | | - |
|---|
| 70 | | - /** |
|---|
| 71 | | - * @return the version of the three entities that can be synchronized |
|---|
| 72 | | - * (Users, DataSet and Settings) |
|---|
| 73 | | - */ |
|---|
| 74 | | - @POST |
|---|
| 75 | | - @Path("/upload1") |
|---|
| 76 | | - @Consumes(MediaType.MULTIPART_FORM_DATA) |
|---|
| 77 | | - @Produces({ |
|---|
| 78 | | - MediaType.APPLICATION_JSON |
|---|
| 79 | | - }) |
|---|
| 80 | | - public Response testFile1(@MultipartForm FileUploadForm mfdi) { |
|---|
| 81 | | - LOG.info("FORM: texto: {}, file: {}", mfdi.getTexto(), new String(mfdi.getFile())); |
|---|
| 82 | | - return Response.ok("OK").build(); |
|---|
| 83 | | - } |
|---|
| 84 | | - |
|---|
| 85 | | -// @GET |
|---|
| 86 | | -// @Path("/current/{license}") |
|---|
| 87 | | -// @Produces({ |
|---|
| 88 | | -// MediaType.APPLICATION_JSON |
|---|
| 89 | | -// }) |
|---|
| 90 | | -// public ServiceResponse<ServerConfigVersions> testFile(@PathParam("license") String license, |
|---|
| 91 | | -// @DefaultValue("-1") @QueryParam("minorVersion") int minorVersion, @DefaultValue("-1") @QueryParam("majorVersion") int majorVersion) { |
|---|
| 92 | | -// |
|---|
| 93 | | -// LOG.info("Called 'current' service with license: {}", license); |
|---|
| 94 | | -// ServiceResponse<ServerConfigVersions> response = new ServiceResponse<ServerConfigVersions>(); |
|---|
| 95 | | -// |
|---|
| 96 | | -// return response; |
|---|
| 97 | | -// } |
|---|
| 98 | | - |
|---|
| 99 | | - public static class FileUploadForm { |
|---|
| 100 | | - |
|---|
| 101 | | - @FormParam("file1") |
|---|
| 102 | | - @PartType("application/octet-stream") |
|---|
| 103 | | - private byte[] file; |
|---|
| 104 | | - |
|---|
| 105 | | - @FormParam("texto1") |
|---|
| 106 | | - @PartType("text/plain") |
|---|
| 107 | | - private String texto; |
|---|
| 108 | | - |
|---|
| 109 | | - public FileUploadForm() { |
|---|
| 110 | | - } |
|---|
| 111 | | - |
|---|
| 112 | | - public byte[] getFile() { |
|---|
| 113 | | - return file; |
|---|
| 114 | | - } |
|---|
| 115 | | - |
|---|
| 116 | | - public void setFile(byte[] file) { |
|---|
| 117 | | - this.file = file; |
|---|
| 118 | | - } |
|---|
| 119 | | - |
|---|
| 120 | | - public void setTexto(final String texto) { |
|---|
| 121 | | - this.texto = texto; |
|---|
| 122 | | - } |
|---|
| 123 | | - |
|---|
| 124 | | - public String getTexto() { |
|---|
| 125 | | - return texto; |
|---|
| 126 | | - } |
|---|
| 127 | | - |
|---|
| 128 | | - } |
|---|
| 129 | | -} |
|---|
| .. | .. |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | import javax.annotation.security.RolesAllowed; |
|---|
| 8 | 8 | import javax.inject.Inject; |
|---|
| 9 | | -import javax.inject.Provider; |
|---|
| 10 | 9 | import javax.persistence.EntityManager; |
|---|
| 11 | 10 | import javax.persistence.TypedQuery; |
|---|
| 12 | 11 | import javax.servlet.http.HttpServletRequest; |
|---|
| 12 | +import javax.transaction.Transactional; |
|---|
| 13 | 13 | import javax.ws.rs.Consumes; |
|---|
| 14 | 14 | import javax.ws.rs.DELETE; |
|---|
| 15 | 15 | import javax.ws.rs.GET; |
|---|
| .. | .. |
|---|
| 39 | 39 | import org.apache.logging.log4j.LogManager; |
|---|
| 40 | 40 | import org.apache.logging.log4j.Logger; |
|---|
| 41 | 41 | |
|---|
| 42 | | -import com.google.inject.persist.Transactional; |
|---|
| 43 | | - |
|---|
| 44 | 42 | /** |
|---|
| 45 | 43 | * LicenseType resource, this service will provide methods to create, modify and |
|---|
| 46 | 44 | * delete license types |
|---|
| .. | .. |
|---|
| 56 | 54 | TokenHelper tokenHelper; |
|---|
| 57 | 55 | |
|---|
| 58 | 56 | @Inject |
|---|
| 59 | | - Provider<EntityManager> emProvider; |
|---|
| 57 | + EntityManager em; |
|---|
| 60 | 58 | |
|---|
| 61 | 59 | public LicenseTypeResource() { |
|---|
| 62 | 60 | } |
|---|
| .. | .. |
|---|
| 74 | 72 | public Response index() { |
|---|
| 75 | 73 | LOG.info("Getting license types list "); |
|---|
| 76 | 74 | |
|---|
| 77 | | - EntityManager em = emProvider.get(); |
|---|
| 75 | + // EntityManager em = emProvider.get(); |
|---|
| 78 | 76 | em.clear(); |
|---|
| 79 | 77 | TypedQuery<LicenseType> q = em.createNamedQuery("list-license_types", LicenseType.class); |
|---|
| 80 | 78 | List<LicenseType> list = q.getResultList(); |
|---|
| .. | .. |
|---|
| 100 | 98 | return Response.status(Status.NOT_FOUND).build(); |
|---|
| 101 | 99 | } |
|---|
| 102 | 100 | |
|---|
| 103 | | - EntityManager em = emProvider.get(); |
|---|
| 101 | + // EntityManager em = emProvider.get(); |
|---|
| 104 | 102 | em.clear(); |
|---|
| 105 | 103 | LicenseType lt = em.find(LicenseType.class, Integer.parseInt(ltid)); |
|---|
| 106 | 104 | if (lt == null) { |
|---|
| .. | .. |
|---|
| 121 | 119 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 122 | 120 | public Response create(LicenseType lt, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 123 | 121 | LOG.info("Creating new license type"); |
|---|
| 124 | | - EntityManager em = emProvider.get(); |
|---|
| 122 | + // EntityManager em = emProvider.get(); |
|---|
| 125 | 123 | |
|---|
| 126 | 124 | try { |
|---|
| 127 | 125 | setApplication(lt, lt.getApplicationId(), em); |
|---|
| .. | .. |
|---|
| 162 | 160 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 163 | 161 | public Response modify(LicenseType lt, @PathParam("ltid") String ltid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 164 | 162 | LOG.info("Modifying license type with id: {}", ltid); |
|---|
| 165 | | - EntityManager em = emProvider.get(); |
|---|
| 163 | + // EntityManager em = emProvider.get(); |
|---|
| 166 | 164 | LicenseType currentlt = em.find(LicenseType.class, Integer.parseInt(ltid)); |
|---|
| 167 | 165 | if (currentlt == null) { |
|---|
| 168 | 166 | LOG.error("LicenseType with id {} not found in DB", ltid); |
|---|
| .. | .. |
|---|
| 229 | 227 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 230 | 228 | public Response delete(@PathParam("ltid") String ltid, @Context HttpServletRequest request) { |
|---|
| 231 | 229 | LOG.info("Deleting app with id: {}", ltid); |
|---|
| 232 | | - EntityManager em = emProvider.get(); |
|---|
| 230 | + // EntityManager em = emProvider.get(); |
|---|
| 233 | 231 | LicenseType app = em.find(LicenseType.class, Integer.parseInt(ltid)); |
|---|
| 234 | 232 | if (app == null) { |
|---|
| 235 | 233 | LOG.error("LicenseType with id {} can not be deleted, It was not found in DB", ltid); |
|---|
| .. | .. |
|---|
| 6 | 6 | import java.util.Set; |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | import javax.annotation.security.RolesAllowed; |
|---|
| 9 | | -import javax.inject.Inject; |
|---|
| 10 | | -import javax.inject.Provider; |
|---|
| 9 | +import javax.enterprise.context.RequestScoped; |
|---|
| 11 | 10 | import javax.persistence.EntityManager; |
|---|
| 12 | 11 | import javax.persistence.TypedQuery; |
|---|
| 13 | 12 | import javax.servlet.http.HttpServletRequest; |
|---|
| 13 | +import javax.transaction.Transactional; |
|---|
| 14 | 14 | import javax.ws.rs.Consumes; |
|---|
| 15 | 15 | import javax.ws.rs.DELETE; |
|---|
| 16 | 16 | import javax.ws.rs.GET; |
|---|
| .. | .. |
|---|
| 30 | 30 | import net.curisit.securis.SeCurisException; |
|---|
| 31 | 31 | import net.curisit.securis.db.Organization; |
|---|
| 32 | 32 | import net.curisit.securis.db.User; |
|---|
| 33 | +import net.curisit.securis.ioc.MyTrans; |
|---|
| 33 | 34 | import net.curisit.securis.security.BasicSecurityContext; |
|---|
| 34 | 35 | import net.curisit.securis.security.Securable; |
|---|
| 35 | 36 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 36 | 37 | |
|---|
| 37 | 38 | import org.apache.logging.log4j.LogManager; |
|---|
| 38 | 39 | import org.apache.logging.log4j.Logger; |
|---|
| 39 | | - |
|---|
| 40 | | -import com.google.inject.persist.Transactional; |
|---|
| 41 | 40 | |
|---|
| 42 | 41 | /** |
|---|
| 43 | 42 | * Organization resource, this service will provide methods to create, modify |
|---|
| .. | .. |
|---|
| 46 | 45 | * @author roberto <roberto.sanchez@curisit.net> |
|---|
| 47 | 46 | */ |
|---|
| 48 | 47 | @Path("/organization") |
|---|
| 48 | +@RequestScoped |
|---|
| 49 | 49 | public class OrganizationResource { |
|---|
| 50 | 50 | |
|---|
| 51 | 51 | private static final Logger LOG = LogManager.getLogger(OrganizationResource.class); |
|---|
| 52 | 52 | |
|---|
| 53 | | - @Inject |
|---|
| 54 | | - private Provider<EntityManager> emProvider; |
|---|
| 53 | + @Context |
|---|
| 54 | + EntityManager em; |
|---|
| 55 | + |
|---|
| 56 | + @Context |
|---|
| 57 | + BasicSecurityContext bsc; |
|---|
| 55 | 58 | |
|---|
| 56 | 59 | public OrganizationResource() { |
|---|
| 57 | 60 | } |
|---|
| .. | .. |
|---|
| 66 | 69 | MediaType.APPLICATION_JSON |
|---|
| 67 | 70 | }) |
|---|
| 68 | 71 | @Securable |
|---|
| 69 | | - public Response index(@Context BasicSecurityContext bsc) { |
|---|
| 72 | + public Response index() { |
|---|
| 70 | 73 | LOG.info("Getting organizations list "); |
|---|
| 71 | 74 | |
|---|
| 72 | | - EntityManager em = emProvider.get(); |
|---|
| 75 | + // EntityManager em = emProvider.get(); |
|---|
| 73 | 76 | em.clear(); |
|---|
| 74 | 77 | TypedQuery<Organization> q; |
|---|
| 75 | 78 | if (bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) { |
|---|
| .. | .. |
|---|
| 101 | 104 | return Response.status(Status.NOT_FOUND).build(); |
|---|
| 102 | 105 | } |
|---|
| 103 | 106 | |
|---|
| 104 | | - EntityManager em = emProvider.get(); |
|---|
| 107 | + // EntityManager em = emProvider.get(); |
|---|
| 105 | 108 | em.clear(); |
|---|
| 106 | 109 | Organization org = em.find(Organization.class, Integer.parseInt(orgid)); |
|---|
| 107 | 110 | if (org == null) { |
|---|
| .. | .. |
|---|
| 128 | 131 | @Produces({ |
|---|
| 129 | 132 | MediaType.APPLICATION_JSON |
|---|
| 130 | 133 | }) |
|---|
| 131 | | - @Transactional |
|---|
| 134 | + @MyTrans |
|---|
| 132 | 135 | @Securable |
|---|
| 133 | 136 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 134 | | - public Response create(Organization org, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 137 | + public Response create(Organization org) { |
|---|
| 135 | 138 | LOG.info("Creating new organization"); |
|---|
| 136 | | - EntityManager em = emProvider.get(); |
|---|
| 139 | + // EntityManager em = emProvider.get(); |
|---|
| 137 | 140 | |
|---|
| 138 | 141 | try { |
|---|
| 139 | 142 | this.setParentOrg(org, org.getParentOrgId(), em); |
|---|
| .. | .. |
|---|
| 159 | 162 | org.setUsers(users); |
|---|
| 160 | 163 | org.setCreationTimestamp(new Date()); |
|---|
| 161 | 164 | em.persist(org); |
|---|
| 162 | | - |
|---|
| 163 | 165 | return Response.ok(org).build(); |
|---|
| 164 | 166 | } |
|---|
| 165 | 167 | |
|---|
| .. | .. |
|---|
| 205 | 207 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 206 | 208 | public Response modify(Organization org, @PathParam("orgid") String orgid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 207 | 209 | LOG.info("Modifying organization with id: {}", orgid); |
|---|
| 208 | | - EntityManager em = emProvider.get(); |
|---|
| 210 | + // EntityManager em = emProvider.get(); |
|---|
| 209 | 211 | Organization currentOrg = em.find(Organization.class, Integer.parseInt(orgid)); |
|---|
| 210 | 212 | if (currentOrg == null) { |
|---|
| 211 | 213 | LOG.error("Organization with id {} not found in DB", orgid); |
|---|
| .. | .. |
|---|
| 250 | 252 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 251 | 253 | public Response delete(@PathParam("orgid") String orgid, @Context HttpServletRequest request) { |
|---|
| 252 | 254 | LOG.info("Deleting organization with id: {}", orgid); |
|---|
| 253 | | - EntityManager em = emProvider.get(); |
|---|
| 255 | + // EntityManager em = emProvider.get(); |
|---|
| 254 | 256 | Organization org = em.find(Organization.class, Integer.parseInt(orgid)); |
|---|
| 255 | 257 | if (org == null) { |
|---|
| 256 | 258 | LOG.error("Organization with id {} can not be deleted, It was not found in DB", orgid); |
|---|
| .. | .. |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | import javax.annotation.security.RolesAllowed; |
|---|
| 9 | 9 | import javax.inject.Inject; |
|---|
| 10 | | -import javax.inject.Provider; |
|---|
| 11 | 10 | import javax.persistence.EntityManager; |
|---|
| 12 | 11 | import javax.persistence.TypedQuery; |
|---|
| 12 | +import javax.transaction.Transactional; |
|---|
| 13 | 13 | import javax.ws.rs.Consumes; |
|---|
| 14 | 14 | import javax.ws.rs.DELETE; |
|---|
| 15 | 15 | import javax.ws.rs.FormParam; |
|---|
| .. | .. |
|---|
| 46 | 46 | import org.apache.logging.log4j.LogManager; |
|---|
| 47 | 47 | import org.apache.logging.log4j.Logger; |
|---|
| 48 | 48 | |
|---|
| 49 | | -import com.google.inject.persist.Transactional; |
|---|
| 50 | | - |
|---|
| 51 | 49 | /** |
|---|
| 52 | 50 | * Pack resource, this service will provide methods to create, modify and delete |
|---|
| 53 | 51 | * packs |
|---|
| .. | .. |
|---|
| 63 | 61 | TokenHelper tokenHelper; |
|---|
| 64 | 62 | |
|---|
| 65 | 63 | @Inject |
|---|
| 66 | | - Provider<EntityManager> emProvider; |
|---|
| 64 | + EntityManager em; |
|---|
| 67 | 65 | |
|---|
| 68 | 66 | @Inject |
|---|
| 69 | 67 | private LicenseHelper licenseHelper; |
|---|
| .. | .. |
|---|
| 81 | 79 | public Response index(@Context BasicSecurityContext bsc) { |
|---|
| 82 | 80 | LOG.info("Getting packs list "); |
|---|
| 83 | 81 | |
|---|
| 84 | | - EntityManager em = emProvider.get(); |
|---|
| 82 | + // EntityManager em = emProvider.get(); |
|---|
| 85 | 83 | em.clear(); |
|---|
| 86 | 84 | |
|---|
| 87 | 85 | TypedQuery<Pack> q; |
|---|
| .. | .. |
|---|
| 123 | 121 | return Response.status(Status.NOT_FOUND).build(); |
|---|
| 124 | 122 | } |
|---|
| 125 | 123 | |
|---|
| 126 | | - EntityManager em = emProvider.get(); |
|---|
| 124 | + // EntityManager em = emProvider.get(); |
|---|
| 127 | 125 | em.clear(); |
|---|
| 128 | 126 | Pack pack = em.find(Pack.class, packId); |
|---|
| 129 | 127 | if (pack == null) { |
|---|
| .. | .. |
|---|
| 148 | 146 | @Transactional |
|---|
| 149 | 147 | public Response create(Pack pack, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 150 | 148 | LOG.info("Creating new pack"); |
|---|
| 151 | | - EntityManager em = emProvider.get(); |
|---|
| 149 | + // EntityManager em = emProvider.get(); |
|---|
| 152 | 150 | |
|---|
| 153 | 151 | if (checkIfCodeExists(pack.getCode(), em)) { |
|---|
| 154 | 152 | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The pack code is already used in an existing pack"); |
|---|
| .. | .. |
|---|
| 213 | 211 | MediaType.TEXT_PLAIN |
|---|
| 214 | 212 | }) |
|---|
| 215 | 213 | public Response getCodeSuffix(@PathParam("packId") Integer packId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 216 | | - EntityManager em = emProvider.get(); |
|---|
| 214 | + // EntityManager em = emProvider.get(); |
|---|
| 217 | 215 | |
|---|
| 218 | 216 | if (packId == null) { |
|---|
| 219 | 217 | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The pack code is mandatory"); |
|---|
| .. | .. |
|---|
| 250 | 248 | }) |
|---|
| 251 | 249 | public Response modify(Pack pack, @PathParam("packId") Integer packId) { |
|---|
| 252 | 250 | LOG.info("Modifying pack with id: {}", packId); |
|---|
| 253 | | - EntityManager em = emProvider.get(); |
|---|
| 251 | + // EntityManager em = emProvider.get(); |
|---|
| 254 | 252 | Pack currentPack = em.find(Pack.class, packId); |
|---|
| 255 | 253 | |
|---|
| 256 | 254 | try { |
|---|
| .. | .. |
|---|
| 305 | 303 | }) |
|---|
| 306 | 304 | public Response activate(@PathParam("packId") Integer packId) throws SeCurisServiceException { |
|---|
| 307 | 305 | LOG.info("Activating pack with id: {}", packId); |
|---|
| 308 | | - EntityManager em = emProvider.get(); |
|---|
| 306 | + // EntityManager em = emProvider.get(); |
|---|
| 309 | 307 | |
|---|
| 310 | 308 | Pack currentPack = em.find(Pack.class, packId); |
|---|
| 311 | 309 | |
|---|
| .. | .. |
|---|
| 331 | 329 | }) |
|---|
| 332 | 330 | public Response onhold(@PathParam("packId") Integer packId) throws SeCurisServiceException { |
|---|
| 333 | 331 | LOG.info("Putting On hold pack with id: {}", packId); |
|---|
| 334 | | - EntityManager em = emProvider.get(); |
|---|
| 332 | + // EntityManager em = emProvider.get(); |
|---|
| 335 | 333 | |
|---|
| 336 | 334 | Pack currentPack = em.find(Pack.class, packId); |
|---|
| 337 | 335 | |
|---|
| .. | .. |
|---|
| 358 | 356 | public Response cancel(@PathParam("packId") Integer packId, @FormParam("reason") String reason, @Context BasicSecurityContext bsc) |
|---|
| 359 | 357 | throws SeCurisServiceException { |
|---|
| 360 | 358 | LOG.info("Cancelling pack with id: {}", packId); |
|---|
| 361 | | - EntityManager em = emProvider.get(); |
|---|
| 359 | + // EntityManager em = emProvider.get(); |
|---|
| 362 | 360 | |
|---|
| 363 | 361 | Pack currentPack = em.find(Pack.class, packId); |
|---|
| 364 | 362 | |
|---|
| .. | .. |
|---|
| 401 | 399 | }) |
|---|
| 402 | 400 | public Response delete(@PathParam("packId") String packId) throws SeCurisServiceException { |
|---|
| 403 | 401 | LOG.info("Deleting pack with id: {}", packId); |
|---|
| 404 | | - EntityManager em = emProvider.get(); |
|---|
| 402 | + // EntityManager em = emProvider.get(); |
|---|
| 405 | 403 | Pack pack = em.find(Pack.class, Integer.parseInt(packId)); |
|---|
| 406 | 404 | if (pack == null) { |
|---|
| 407 | 405 | LOG.error("Pack with id {} can not be deleted, It was not found in DB", packId); |
|---|
| .. | .. |
|---|
| 6 | 6 | import java.util.Set; |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | import javax.annotation.security.RolesAllowed; |
|---|
| 9 | +import javax.enterprise.context.RequestScoped; |
|---|
| 9 | 10 | import javax.inject.Inject; |
|---|
| 10 | | -import javax.inject.Provider; |
|---|
| 11 | 11 | import javax.persistence.EntityManager; |
|---|
| 12 | 12 | import javax.persistence.PersistenceException; |
|---|
| 13 | 13 | import javax.persistence.TypedQuery; |
|---|
| 14 | 14 | import javax.servlet.http.HttpServletRequest; |
|---|
| 15 | +import javax.transaction.Transactional; |
|---|
| 15 | 16 | import javax.ws.rs.Consumes; |
|---|
| 16 | 17 | import javax.ws.rs.DELETE; |
|---|
| 17 | 18 | import javax.ws.rs.FormParam; |
|---|
| .. | .. |
|---|
| 35 | 36 | import net.curisit.securis.db.User; |
|---|
| 36 | 37 | import net.curisit.securis.security.BasicSecurityContext; |
|---|
| 37 | 38 | import net.curisit.securis.security.Securable; |
|---|
| 39 | +import net.curisit.securis.services.exception.SeCurisServiceException; |
|---|
| 40 | +import net.curisit.securis.services.exception.SeCurisServiceException.ErrorCodes; |
|---|
| 38 | 41 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 39 | 42 | |
|---|
| 40 | 43 | import org.apache.logging.log4j.LogManager; |
|---|
| 41 | 44 | import org.apache.logging.log4j.Logger; |
|---|
| 42 | | - |
|---|
| 43 | | -import com.google.inject.persist.Transactional; |
|---|
| 44 | 45 | |
|---|
| 45 | 46 | /** |
|---|
| 46 | 47 | * User resource |
|---|
| .. | .. |
|---|
| 48 | 49 | * @author roberto <roberto.sanchez@curisit.net> |
|---|
| 49 | 50 | */ |
|---|
| 50 | 51 | @Path("/user") |
|---|
| 52 | +@RequestScoped |
|---|
| 51 | 53 | public class UserResource { |
|---|
| 52 | 54 | |
|---|
| 53 | 55 | @Inject |
|---|
| 54 | 56 | TokenHelper tokenHelper; |
|---|
| 55 | 57 | |
|---|
| 56 | 58 | @Inject |
|---|
| 57 | | - Provider<EntityManager> emProvider; |
|---|
| 59 | + EntityManager em; |
|---|
| 58 | 60 | |
|---|
| 59 | 61 | private static final Logger LOG = LogManager.getLogger(UserResource.class); |
|---|
| 60 | 62 | |
|---|
| .. | .. |
|---|
| 75 | 77 | public Response index() { |
|---|
| 76 | 78 | LOG.info("Getting users list "); |
|---|
| 77 | 79 | |
|---|
| 78 | | - EntityManager em = emProvider.get(); |
|---|
| 80 | + // EntityManager em = emProvider.get(); |
|---|
| 79 | 81 | em.clear(); |
|---|
| 80 | 82 | TypedQuery<User> q = em.createNamedQuery("list-users", User.class); |
|---|
| 81 | 83 | |
|---|
| .. | .. |
|---|
| 102 | 104 | return Response.status(Status.NOT_FOUND).build(); |
|---|
| 103 | 105 | } |
|---|
| 104 | 106 | |
|---|
| 105 | | - EntityManager em = emProvider.get(); |
|---|
| 107 | + // EntityManager em = emProvider.get(); |
|---|
| 106 | 108 | em.clear(); |
|---|
| 107 | 109 | User lt = em.find(User.class, uid); |
|---|
| 108 | 110 | if (lt == null) { |
|---|
| .. | .. |
|---|
| 123 | 125 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 124 | 126 | public Response create(User user, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 125 | 127 | LOG.info("Creating new user"); |
|---|
| 126 | | - EntityManager em = emProvider.get(); |
|---|
| 128 | + // EntityManager em = emProvider.get(); |
|---|
| 127 | 129 | User currentUser = em.find(User.class, user.getUsername()); |
|---|
| 128 | 130 | if (currentUser != null) { |
|---|
| 129 | 131 | LOG.info("User with id {} was found in DB, we'll try to modify it", user.getUsername()); |
|---|
| .. | .. |
|---|
| 179 | 181 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 180 | 182 | public Response modify(User user, @PathParam("uid") String uid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 181 | 183 | LOG.info("Modifying user with id: {}", uid); |
|---|
| 182 | | - EntityManager em = emProvider.get(); |
|---|
| 184 | + // EntityManager em = emProvider.get(); |
|---|
| 183 | 185 | User currentUser = em.find(User.class, uid); |
|---|
| 184 | 186 | if (currentUser == null) { |
|---|
| 185 | 187 | LOG.info("User with id {} not found in DB, we'll try to create it", uid); |
|---|
| .. | .. |
|---|
| 222 | 224 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 223 | 225 | public Response delete(@PathParam("uid") String uid, @Context HttpServletRequest request) { |
|---|
| 224 | 226 | LOG.info("Deleting app with id: {}", uid); |
|---|
| 225 | | - EntityManager em = emProvider.get(); |
|---|
| 227 | + // EntityManager em = emProvider.get(); |
|---|
| 226 | 228 | User app = em.find(User.class, uid); |
|---|
| 227 | 229 | if (app == null) { |
|---|
| 228 | 230 | LOG.error("User with id {} can not be deleted, It was not found in DB", uid); |
|---|
| .. | .. |
|---|
| 238 | 240 | @Produces({ |
|---|
| 239 | 241 | MediaType.APPLICATION_JSON |
|---|
| 240 | 242 | }) |
|---|
| 241 | | - public Response login(@FormParam("username") String username, @FormParam("password") String password, @Context HttpServletRequest request) { |
|---|
| 243 | + public Response login(@FormParam("username") String username, @FormParam("password") String password, @Context HttpServletRequest request) |
|---|
| 244 | + throws SeCurisServiceException { |
|---|
| 242 | 245 | LOG.info("index session: " + request.getSession()); |
|---|
| 243 | 246 | LOG.info("user: {}, pass: {}", username, password); |
|---|
| 244 | 247 | LOG.info("is user in role: {} == {} ? ", "advance", request.isUserInRole("advance")); |
|---|
| 245 | 248 | LOG.info("is user in role: {} == {} ? ", "admin", request.isUserInRole("admin")); |
|---|
| 246 | 249 | |
|---|
| 247 | | - EntityManager em = emProvider.get(); |
|---|
| 250 | + // EntityManager em = emProvider.get(); |
|---|
| 248 | 251 | User user = em.find(User.class, username); |
|---|
| 249 | 252 | if (user == null) { |
|---|
| 250 | 253 | LOG.error("Inknown username {} used in login service", username); |
|---|
| 251 | | - return Response.status(Status.UNAUTHORIZED).build(); |
|---|
| 254 | + throw new SeCurisServiceException(ErrorCodes.UNAUTHORIZED_ACCESS, "Wrong credentials"); |
|---|
| 252 | 255 | } |
|---|
| 253 | 256 | String securedPassword = Utils.sha256(password); |
|---|
| 254 | 257 | |
|---|
| 255 | 258 | if (securedPassword == null || !securedPassword.equals(user.getPassword())) { |
|---|
| 256 | | - // TODO: Code to test exception handling |
|---|
| 257 | | - return Response.status(Status.UNAUTHORIZED).build(); |
|---|
| 259 | + throw new SeCurisServiceException(ErrorCodes.UNAUTHORIZED_ACCESS, "Wrong credentials"); |
|---|
| 258 | 260 | } |
|---|
| 259 | 261 | user.setLastLogin(new Date()); |
|---|
| 260 | 262 | em.getTransaction().begin(); |
|---|
| .. | .. |
|---|
| 8 | 8 | import java.util.Map; |
|---|
| 9 | 9 | import java.util.Set; |
|---|
| 10 | 10 | |
|---|
| 11 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 11 | 12 | import javax.inject.Inject; |
|---|
| 12 | | -import javax.inject.Singleton; |
|---|
| 13 | 13 | import javax.persistence.EntityManager; |
|---|
| 14 | 14 | import javax.persistence.TypedQuery; |
|---|
| 15 | 15 | |
|---|
| .. | .. |
|---|
| 28 | 28 | import org.apache.logging.log4j.LogManager; |
|---|
| 29 | 29 | import org.apache.logging.log4j.Logger; |
|---|
| 30 | 30 | |
|---|
| 31 | | -@Singleton |
|---|
| 31 | +@ApplicationScoped |
|---|
| 32 | 32 | public class LicenseHelper { |
|---|
| 33 | 33 | |
|---|
| 34 | 34 | @SuppressWarnings("unused") |
|---|
| .. | .. |
|---|
| 1 | 1 | package net.curisit.securis.services.helpers; |
|---|
| 2 | 2 | |
|---|
| 3 | | -import javax.inject.Singleton; |
|---|
| 3 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 4 | 4 | import javax.persistence.EntityManager; |
|---|
| 5 | 5 | import javax.ws.rs.core.Response.Status; |
|---|
| 6 | 6 | |
|---|
| .. | .. |
|---|
| 8 | 8 | import net.curisit.securis.security.BasicSecurityContext; |
|---|
| 9 | 9 | import net.curisit.securis.services.exception.SeCurisServiceException; |
|---|
| 10 | 10 | |
|---|
| 11 | | -@Singleton |
|---|
| 11 | +@ApplicationScoped |
|---|
| 12 | 12 | public class UserHelper { |
|---|
| 13 | 13 | |
|---|
| 14 | 14 | public User getUser(BasicSecurityContext bsc, EntityManager em) throws SeCurisServiceException { |
|---|
| .. | .. |
|---|
| 6 | 6 | import java.util.List; |
|---|
| 7 | 7 | import java.util.Map; |
|---|
| 8 | 8 | |
|---|
| 9 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 9 | 10 | import javax.inject.Inject; |
|---|
| 10 | | -import javax.inject.Singleton; |
|---|
| 11 | 11 | |
|---|
| 12 | 12 | import org.apache.logging.log4j.LogManager; |
|---|
| 13 | 13 | import org.apache.logging.log4j.Logger; |
|---|
| .. | .. |
|---|
| 18 | 18 | * |
|---|
| 19 | 19 | * @author roberto <roberto.sanchez@curisit.net> |
|---|
| 20 | 20 | */ |
|---|
| 21 | | -@Singleton |
|---|
| 21 | +@ApplicationScoped |
|---|
| 22 | 22 | public class CacheTTL { |
|---|
| 23 | 23 | |
|---|
| 24 | 24 | private static final Logger LOG = LogManager.getLogger(CacheTTL.class); |
|---|
| .. | .. |
|---|
| 14 | 14 | import java.util.concurrent.Executor; |
|---|
| 15 | 15 | import java.util.concurrent.Executors; |
|---|
| 16 | 16 | |
|---|
| 17 | | -import javax.inject.Singleton; |
|---|
| 17 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 18 | 18 | |
|---|
| 19 | 19 | import net.curisit.securis.SeCurisException; |
|---|
| 20 | 20 | import net.curisit.securis.services.exception.SeCurisServiceException; |
|---|
| .. | .. |
|---|
| 45 | 45 | * |
|---|
| 46 | 46 | * @author roberto <roberto.sanchez@curisit.net> |
|---|
| 47 | 47 | */ |
|---|
| 48 | | -@Singleton |
|---|
| 48 | +@ApplicationScoped |
|---|
| 49 | 49 | public class EmailManager { |
|---|
| 50 | 50 | |
|---|
| 51 | 51 | private static final Logger LOG = LogManager.getLogger(EmailManager.class); |
|---|
| .. | .. |
|---|
| 7 | 7 | import java.security.NoSuchAlgorithmException; |
|---|
| 8 | 8 | import java.util.Date; |
|---|
| 9 | 9 | |
|---|
| 10 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 10 | 11 | import javax.inject.Inject; |
|---|
| 11 | | -import javax.inject.Singleton; |
|---|
| 12 | 12 | |
|---|
| 13 | 13 | import net.curisit.integrity.commons.Utils; |
|---|
| 14 | 14 | |
|---|
| .. | .. |
|---|
| 17 | 17 | import org.apache.logging.log4j.Logger; |
|---|
| 18 | 18 | import org.jboss.resteasy.util.Base64; |
|---|
| 19 | 19 | |
|---|
| 20 | | -@Singleton |
|---|
| 20 | +@ApplicationScoped |
|---|
| 21 | 21 | public class TokenHelper { |
|---|
| 22 | 22 | |
|---|
| 23 | 23 | private static final Logger LOG = LogManager.getLogger(TokenHelper.class); |
|---|
| .. | .. |
|---|
| 2 | 2 | <persistence version="2.0" |
|---|
| 3 | 3 | xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|---|
| 4 | 4 | xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> |
|---|
| 5 | | - <persistence-unit name="localdb" transaction-type="RESOURCE_LOCAL"> |
|---|
| 5 | + <persistence-unit name="localdb" > |
|---|
| 6 | 6 | <description>SeCuris LocalDB</description> |
|---|
| 7 | 7 | <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> |
|---|
| 8 | + <non-jta-data-source>java:comp/env/SeCurisDS</non-jta-data-source> |
|---|
| 8 | 9 | <shared-cache-mode>NONE</shared-cache-mode> |
|---|
| 9 | | - |
|---|
| 10 | | -<!-- <jta-data-source>java:comp/env/jdbc/SeCurisDS</jta-data-source> |
|---|
| 11 | | - --> |
|---|
| 12 | | - <!-- <class>net.curisit.securis.db.UserSettingsUnits</class> --> |
|---|
| 13 | | - |
|---|
| 14 | 10 | <properties> |
|---|
| 15 | 11 | <property name="hibernate.cache.provider_class" value="org.hibernate.cache.internal.NoCachingRegionFactory"/> |
|---|
| 16 | 12 | <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" /> |
|---|
| 17 | | - <property name="hibernate.connection.datasource" value="java:comp/env/jdbc/SeCurisDS" /> |
|---|
| 13 | + <!-- <property name="hibernate.connection.datasource" value="java:comp/env/jdbc/SeCurisDS" /> --> |
|---|
| 18 | 14 | |
|---|
| 19 | 15 | <property name="hibernate.cache.use_second_level_cache" value="false" /> |
|---|
| 20 | 16 | <!-- <property name="hibernate.show_sql" value="true" /> --> |
|---|
| .. | .. |
|---|
| 1 | +<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|---|
| 2 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_1.xsd"> |
|---|
| 3 | +<interceptors> |
|---|
| 4 | + <class>net.curisit.securis.ioc.TransactionsManager</class> |
|---|
| 5 | + </interceptors> |
|---|
| 6 | +</beans> |
|---|
| 7 | + |
|---|
| .. | .. |
|---|
| 29 | 29 | |
|---|
| 30 | 30 | |
|---|
| 31 | 31 | <context-param> |
|---|
| 32 | | - <param-name>resteasy.guice.modules</param-name> |
|---|
| 33 | | - <param-value>net.curisit.securis.ioc.SecurisModule,net.curisit.securis.ioc.RequestsModule</param-value> |
|---|
| 34 | | - </context-param> |
|---|
| 35 | | - <context-param> |
|---|
| 36 | 32 | <param-name>resteasy.role.based.security</param-name> |
|---|
| 37 | 33 | <param-value>true</param-value> |
|---|
| 38 | 34 | </context-param> |
|---|
| .. | .. |
|---|
| 40 | 36 | <param-name>resteasy.providers</param-name> |
|---|
| 41 | 37 | <param-value>net.curisit.securis.DefaultExceptionHandler</param-value> |
|---|
| 42 | 38 | </context-param> |
|---|
| 39 | + <context-param> |
|---|
| 40 | + <param-name>resteasy.injector.factory</param-name> |
|---|
| 41 | + <param-value>org.jboss.resteasy.cdi.CdiInjectorFactory</param-value> |
|---|
| 42 | + </context-param> |
|---|
| 43 | 43 | |
|---|
| 44 | | - |
|---|
| 44 | + |
|---|
| 45 | 45 | <filter> |
|---|
| 46 | 46 | <filter-name>Resteasy</filter-name> |
|---|
| 47 | 47 | <filter-class> |
|---|
| 48 | 48 | org.jboss.resteasy.plugins.server.servlet.FilterDispatcher |
|---|
| 49 | 49 | </filter-class> |
|---|
| 50 | | - |
|---|
| 50 | + <init-param> |
|---|
| 51 | + <param-name>javax.ws.rs.Application</param-name> |
|---|
| 52 | + <param-value>net.curisit.securis.RestServicesApplication</param-value> |
|---|
| 53 | + </init-param> |
|---|
| 51 | 54 | </filter> |
|---|
| 52 | 55 | |
|---|
| 53 | 56 | <filter-mapping> |
|---|
| 54 | 57 | <filter-name>Resteasy</filter-name> |
|---|
| 55 | 58 | <url-pattern>/*</url-pattern> |
|---|
| 56 | 59 | </filter-mapping> |
|---|
| 57 | | - |
|---|
| 58 | | - |
|---|
| 59 | | - <listener> |
|---|
| 60 | | - <listener-class> |
|---|
| 61 | | - net.curisit.securis.BootstrapListener |
|---|
| 62 | | - </listener-class> |
|---|
| 63 | | - </listener> |
|---|
| 64 | 60 | |
|---|
| 65 | 61 | <welcome-file-list> |
|---|
| 66 | 62 | <welcome-file>/index.jsp</welcome-file> |
|---|
| .. | .. |
|---|
| 82 | 78 | </security-role> |
|---|
| 83 | 79 | |
|---|
| 84 | 80 | <resource-env-ref> |
|---|
| 85 | | - <resource-env-ref-name>jdbc/SeCurisDS</resource-env-ref-name> |
|---|
| 81 | + <resource-env-ref-name>SeCurisDS</resource-env-ref-name> |
|---|
| 86 | 82 | <resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type> |
|---|
| 87 | | - <res-auth>Container</res-auth> |
|---|
| 83 | +</resource-env-ref> |
|---|
| 84 | + |
|---|
| 85 | +<resource-env-ref> |
|---|
| 86 | + <resource-env-ref-name>BeanManager</resource-env-ref-name> |
|---|
| 87 | + <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type> |
|---|
| 88 | 88 | </resource-env-ref> |
|---|
| 89 | 89 | |
|---|
| 90 | 90 | </web-app> |
|---|