spring-java-config

Spring Security with Java Configuration: How to handle BadCredentialsException from a custom provider

烈酒焚心 提交于 2019-12-03 17:21:14
I need to authenticate some rest services using a token id in the url (or maybe in the request header - but this is not important for now). I am trying to use java configuration to set this up using as a guide this post . My problem is that I do not know how to handle "BadCredentialsException" that is thrown when the authentication fails from the provider. Here is my Security Config: public static class SecurityConfigForRS extends WebSecurityConfigurerAdapter { @Autowired TokenAuthenticationProvider tokenAuthenticationProvider; @Override protected void configure(AuthenticationManagerBuilder

Spring Batch (java-config) executing step after a jobExeuctionDecider

非 Y 不嫁゛ 提交于 2019-12-03 16:12:35
I'm trying to configure a Flow in spring batch using java-config, this flow basically has to do this: Execute a init step(which adds a record in the database), then execute a decider to check file existence, 2.1. IF the files exists it will execute the load job (which is another flow with a bunch of steps in parallel) Execute a finish step (which adds a record in the database), this should always run, even if 2.1 was not executed. I tried to do this configuration, but the finish step never runs: Flow flow = new FlowBuilder<SimpleFlow>("commonFlow") .start(stepBuilderFactory.get("initStep")

Spring Security: Java Config does not work

一笑奈何 提交于 2019-12-03 13:56:51
问题 I am trying to set up a java configurated spring environment including spring security. The application starts without any error, but I am not able to login succeffully. WebAppInitializer import javax.servlet.ServletContext; import javax.servlet.ServletException; import org.springframework.core.annotation.Order; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; @Order(value = 1) public class WebAppInitializer extends

Right way to use @ComponentScan in multi module Java-Config Spring MVC app

℡╲_俬逩灬. 提交于 2019-12-03 10:04:03
问题 I've just started a new spring project, and this time I want to do things "right". In the last project I had issues with multiple registering of certain classes because of multiple @ComponentScan annotations. (i.e. all service classes got registered twice) Basically I'm using the following layout: WebAppInitializer : public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class<?>[] getRootConfigClasses() { return new Class[] {

Spring Java based configuration with static method

独自空忆成欢 提交于 2019-12-03 09:08:37
问题 can any one please advice why we need to declare PropertySourcesPlaceholderConfigurer bean using a static method ? I just found that if I use non-static for below then url will be set to null value instead of taking from property file - @Value("${spring.datasource.url}") private String url; @Bean public static PropertySourcesPlaceholderConfigurer propertyConfig(String profile) { String propertyFileName = "application_"+profile+".properties"; System.out.println(propertyFileName);

Spring Security Java Config - custom AuthenticationProvider and UserDetailsService

风流意气都作罢 提交于 2019-12-03 06:46:51
I use java configuration to configure Spring Security, and I have customized AuthenticationProvider and customized UserDetailsService, to add extra login field following http://forum.spring.io/forum/spring-projects/security/95715-extra-login-fields I have difficulty to add both of the customized Classes into Spring Security framework by using java configuration. As java doc of AuthenticationProvider#authenticationProvider describes: Add authentication based upon the custom AuthenticationProvider that is passed in. Since the AuthenticationProvider implementation is unknown, all customizations

spring autowired aop circular dependency

拜拜、爱过 提交于 2019-12-03 04:14:53
问题 I'm using java config with @ComponentScan in order to initialize my beans and @EnableAspectJAutoProxy(proxyTargetClass=true) to use cglib proxies. In this project we have a lots of generated services autowired between them using @Autowired . It works pretty well. But, for some of these services I've added @Async (I've also added @EnableAsync(proxyTargetClass = true) on my @Configuration class). After that, I'm getting: Caused by: org.springframework.beans.factory

Spring Security: Java Config does not work

荒凉一梦 提交于 2019-12-03 03:11:50
I am trying to set up a java configurated spring environment including spring security. The application starts without any error, but I am not able to login succeffully. WebAppInitializer import javax.servlet.ServletContext; import javax.servlet.ServletException; import org.springframework.core.annotation.Order; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; @Order(value = 1) public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override public void onStartup(ServletContext servletContext) throws

Spring Java based configuration with static method

痴心易碎 提交于 2019-12-03 02:22:53
can any one please advice why we need to declare PropertySourcesPlaceholderConfigurer bean using a static method ? I just found that if I use non-static for below then url will be set to null value instead of taking from property file - @Value("${spring.datasource.url}") private String url; @Bean public static PropertySourcesPlaceholderConfigurer propertyConfig(String profile) { String propertyFileName = "application_"+profile+".properties"; System.out.println(propertyFileName); PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setLocation

Right way to use @ComponentScan in multi module Java-Config Spring MVC app

偶尔善良 提交于 2019-12-03 01:38:19
I've just started a new spring project, and this time I want to do things "right". In the last project I had issues with multiple registering of certain classes because of multiple @ComponentScan annotations. (i.e. all service classes got registered twice) Basically I'm using the following layout: WebAppInitializer : public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class<?>[] getRootConfigClasses() { return new Class[] { RootConfig.class }; } @Override protected Class<?>[] getServletConfigClasses() { return new Class[] {