mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-22 04:18:20 +00:00
Trying to get the web config running
This commit is contained in:
parent
c177cfdadd
commit
f22a603f01
@ -20,9 +20,7 @@ import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import org.springframework.orm.hibernate5.HibernateTransactionManager;
|
||||
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@ -71,7 +69,6 @@ public class AttestationCertificateAuthorityConfiguration implements WebMvcConfi
|
||||
}
|
||||
}
|
||||
|
||||
private static final String CLIENT_FILES_PATH = "file:/etc/hirs/aca/client-files/";
|
||||
|
||||
// @Value("${persistence.db.url}")
|
||||
// private String url;
|
||||
@ -304,15 +301,5 @@ public class AttestationCertificateAuthorityConfiguration implements WebMvcConfi
|
||||
return new SimpleStructConverter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(final ResourceHandlerRegistry resourceHandlerRegistry) {
|
||||
resourceHandlerRegistry.addResourceHandler("/client-files/**")
|
||||
.addResourceLocations(CLIENT_FILES_PATH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureDefaultServletHandling(final DefaultServletHandlerConfigurer configurer) {
|
||||
configurer.enable();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package hirs.attestationca;
|
||||
|
||||
import hirs.attestationca.configuration.PersistenceConfiguration;
|
||||
import hirs.attestationca.persist.DBAppraiserManager;
|
||||
import hirs.attestationca.persist.DBDeviceGroupManager;
|
||||
import hirs.attestationca.persist.DBPolicyManager;
|
||||
@ -7,6 +8,7 @@ import hirs.utils.HIRSProfiles;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
|
||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
@ -14,7 +16,8 @@ import javax.servlet.ServletContextListener;
|
||||
/**
|
||||
* Simply holds a contextInitialized method which will be called when the web app starts.
|
||||
*/
|
||||
public class InitializationListener implements ServletContextListener {
|
||||
public class InitializationListener extends AbstractAnnotationConfigDispatcherServletInitializer
|
||||
implements ServletContextListener {
|
||||
@Override
|
||||
public void contextInitialized(final ServletContextEvent event) {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
@ -37,4 +40,25 @@ public class InitializationListener implements ServletContextListener {
|
||||
public void contextDestroyed(final ServletContextEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getRootConfigClasses() {
|
||||
return new Class[] {
|
||||
AttestationCertificateAuthorityConfiguration.class
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getServletConfigClasses() {
|
||||
return new Class[] {
|
||||
PersistenceConfiguration.class,
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getServletMappings() {
|
||||
return new String[] {
|
||||
"/"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
import org.springframework.web.servlet.view.UrlBasedViewResolver;
|
||||
@ -30,6 +32,8 @@ import java.nio.charset.StandardCharsets;
|
||||
@Import({ AttestationCertificateAuthorityConfiguration.class })
|
||||
public class CommonPageConfiguration implements WebMvcConfigurer {
|
||||
|
||||
private static final String CLIENT_FILES_PATH = "file:/etc/hirs/aca/client-files/";
|
||||
|
||||
/**
|
||||
* @return bean to resolve injected annotation.Value
|
||||
* property expressions for beans.
|
||||
@ -81,4 +85,14 @@ public class CommonPageConfiguration implements WebMvcConfigurer {
|
||||
return resolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(final ResourceHandlerRegistry resourceHandlerRegistry) {
|
||||
resourceHandlerRegistry.addResourceHandler("/client-files/**")
|
||||
.addResourceLocations(CLIENT_FILES_PATH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureDefaultServletHandling(final DefaultServletHandlerConfigurer configurer) {
|
||||
configurer.enable();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user