mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-17 07:43:30 +00:00
SEC-271: removed autowiring by type and explicity introspected the applicationContext to detect the required dependencies of userDetailsService
This commit is contained in:
parent
e3435da9ae
commit
3f7e00c796
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.acegisecurity.config;
|
||||||
|
|
||||||
|
import org.acegisecurity.providers.dao.DaoAuthenticationProvider;
|
||||||
|
import org.acegisecurity.userdetails.UserDetailsService;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
|
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||||
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author vpuri
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class AuthenticationRepositoryDependenciesConfigurer implements BeanFactoryPostProcessor {
|
||||||
|
|
||||||
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||||
|
System.out.println("whyyyy??????");
|
||||||
|
String[] userDetailServices = beanFactory.getBeanNamesForType(UserDetailsService.class);
|
||||||
|
|
||||||
|
String[] authenticationProvider = beanFactory.getBeanNamesForType(DaoAuthenticationProvider.class);
|
||||||
|
|
||||||
|
RootBeanDefinition definition = (RootBeanDefinition) beanFactory.getBeanDefinition(authenticationProvider[0]);
|
||||||
|
|
||||||
|
// there should be only one principal-repository defined, pick the first
|
||||||
|
// one
|
||||||
|
if (userDetailServices.length != 0) {
|
||||||
|
definition.getPropertyValues().addPropertyValue("userDetailsService",
|
||||||
|
new RuntimeBeanReference(userDetailServices[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.acegisecurity.config;
|
||||||
|
|
||||||
|
import org.acegisecurity.ui.rememberme.RememberMeServices;
|
||||||
|
import org.acegisecurity.userdetails.UserDetailsService;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
|
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||||
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author vpuri
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RemeberMeServicesDependenciesConfigurer implements BeanFactoryPostProcessor {
|
||||||
|
|
||||||
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||||
|
|
||||||
|
String [] userDetailServices = beanFactory.getBeanNamesForType(UserDetailsService.class);
|
||||||
|
|
||||||
|
String [] rememberMeService = beanFactory.getBeanNamesForType(RememberMeServices.class);
|
||||||
|
|
||||||
|
RootBeanDefinition definition=(RootBeanDefinition) beanFactory.getBeanDefinition(rememberMeService[0]);
|
||||||
|
|
||||||
|
// there should be only one principal-repository defined, pick the first one
|
||||||
|
if(userDetailServices.length!=0) {
|
||||||
|
definition.getPropertyValues().addPropertyValue("userDetailsService", new RuntimeBeanReference(userDetailServices[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user