SEC-1593: Added tests to try to reproduce issue.
This commit is contained in:
parent
1c8d28501c
commit
b9a98613eb
|
@ -45,6 +45,8 @@ import org.springframework.security.web.servletapi.SecurityContextHolderAwareReq
|
||||||
import org.springframework.security.web.session.SessionManagementFilter
|
import org.springframework.security.web.session.SessionManagementFilter
|
||||||
import org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler
|
import org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler
|
||||||
import org.springframework.security.web.firewall.DefaultHttpFirewall
|
import org.springframework.security.web.firewall.DefaultHttpFirewall
|
||||||
|
import org.springframework.security.BeanNameCollectingPostProcessor
|
||||||
|
import org.springframework.security.authentication.dao.DaoAuthenticationProvider
|
||||||
|
|
||||||
class MiscHttpConfigTests extends AbstractHttpConfigTests {
|
class MiscHttpConfigTests extends AbstractHttpConfigTests {
|
||||||
def 'Minimal configuration parses'() {
|
def 'Minimal configuration parses'() {
|
||||||
|
@ -409,16 +411,26 @@ class MiscHttpConfigTests extends AbstractHttpConfigTests {
|
||||||
* and also has a post processor registered which will modify it.
|
* and also has a post processor registered which will modify it.
|
||||||
*/
|
*/
|
||||||
def httpElementDoesntInterfereWithBeanPostProcessing() {
|
def httpElementDoesntInterfereWithBeanPostProcessing() {
|
||||||
httpAutoConfig {}
|
xml.http('auto-config': 'true', 'entry-point-ref': 'entryPoint') {}
|
||||||
xml.'authentication-manager'() {
|
xml.'authentication-manager'() {
|
||||||
'authentication-provider'('user-service-ref': 'myUserService')
|
'authentication-provider'('user-service-ref': 'myUserService')
|
||||||
|
'authentication-provider'('ref': 'authProvider')
|
||||||
}
|
}
|
||||||
|
bean('authProvider', DaoAuthenticationProvider.class.name, [:], [userDetailsService: 'myUserService'])
|
||||||
|
bean('entryPoint', MockEntryPoint.class.name)
|
||||||
bean('myUserService', PostProcessedMockUserDetailsService)
|
bean('myUserService', PostProcessedMockUserDetailsService)
|
||||||
bean('beanPostProcessor', MockUserServiceBeanPostProcessor)
|
bean('userServicePostProcessor', MockUserServiceBeanPostProcessor)
|
||||||
|
bean('nameCollectingPostProcessor', BeanNameCollectingPostProcessor)
|
||||||
createAppContext("")
|
createAppContext("")
|
||||||
|
def beanPP = appContext.getBean("nameCollectingPostProcessor")
|
||||||
|
Set preInitPPBeans = beanPP.beforeInitPostProcessedBeans
|
||||||
|
Set postInitPPBeans = beanPP.afterInitPostProcessedBeans
|
||||||
|
Set expectedBeans = ['authProvider', 'entryPoint', 'myUserService'] as Set
|
||||||
|
|
||||||
expect:
|
expect:
|
||||||
appContext.getBean("myUserService").getPostProcessorWasHere() == "Hello from the post processor!"
|
appContext.getBean("myUserService").getPostProcessorWasHere() == "Hello from the post processor!"
|
||||||
|
preInitPPBeans.containsAll(expectedBeans)
|
||||||
|
postInitPPBeans.containsAll(expectedBeans)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SEC-934 */
|
/* SEC-934 */
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package org.springframework.security;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luke Taylor
|
||||||
|
*/
|
||||||
|
public class BeanNameCollectingPostProcessor implements BeanPostProcessor {
|
||||||
|
Set<String> beforeInitPostProcessedBeans = new HashSet<String>();
|
||||||
|
Set<String> afterInitPostProcessedBeans = new HashSet<String>();
|
||||||
|
|
||||||
|
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||||
|
if (beanName != null) {
|
||||||
|
beforeInitPostProcessedBeans.add(beanName);
|
||||||
|
}
|
||||||
|
return bean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||||
|
if (beanName != null) {
|
||||||
|
afterInitPostProcessedBeans.add(beanName);
|
||||||
|
}
|
||||||
|
return bean;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue