mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-31 09:12:14 +00:00
SEC-271: Deleted AccessDeniedHandlerBeanDefinitionLocator as the autodetection functionality is implemented in ExceptionTranslationfilter
This commit is contained in:
parent
917030f0a3
commit
4d783d7375
@ -1,50 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.acegisecurity.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.acegisecurity.ui.AccessDeniedHandler;
|
||||
import org.acegisecurity.ui.ExceptionTranslationFilter;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author vpuri
|
||||
*
|
||||
*/
|
||||
public class AccessDeniedHandlerBeanDefinitionLocator implements BeanFactoryPostProcessor {
|
||||
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
|
||||
Map m = beanFactory.getBeansOfType(AccessDeniedHandler.class);
|
||||
|
||||
List l = new ArrayList(m.values());
|
||||
|
||||
|
||||
|
||||
if (m.size() > 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"More than one AccessDeniedHandler beans detected please refer to the one using "
|
||||
+ " [ accessDeniedBeanRef ] " + "attribute");
|
||||
}
|
||||
else if (m.size() == 1) {
|
||||
// use this
|
||||
String[] names = beanFactory.getBeanNamesForType(ExceptionTranslationFilter.class);
|
||||
Assert.notEmpty(names, "No bean of type ExceptionTranslationFilter found in ApplicationContext");
|
||||
RootBeanDefinition definition = (RootBeanDefinition) beanFactory.getBeanDefinition(names[0]);
|
||||
Assert.isAssignable(AccessDeniedHandler.class, l.get(0).getClass());
|
||||
definition.getPropertyValues().addPropertyValue("accessDeniedHandler", l.get(0));
|
||||
}
|
||||
else {
|
||||
// use the default one for now
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user