SEC-271: Fixed IllegalStateException being thrown by LogoutHandlerOrdereResolver and add an assert statement in the unit test
This commit is contained in:
@@ -67,17 +67,21 @@ public class LogoutHandlerOrderResolver implements BeanFactoryPostProcessor {
|
||||
for (int i = 0, n = names.length; i < n; i++) {
|
||||
RootBeanDefinition definition = (RootBeanDefinition) beanFactory.getBeanDefinition(names[i]);
|
||||
|
||||
if (Ordered.class.isAssignableFrom(definition.getBeanClass())) {
|
||||
definition.getPropertyValues().addPropertyValue("order", new Integer(getOrder(definition.getBeanClass())));
|
||||
} else {
|
||||
definition.getPropertyValues().addPropertyValue("order", new Integer(Integer.MAX_VALUE));
|
||||
if (definition.hasBeanClass()) {
|
||||
if (Ordered.class.isAssignableFrom(definition.getBeanClass())) {
|
||||
definition.getPropertyValues().addPropertyValue("order",
|
||||
new Integer(getOrder(definition.getBeanClass())));
|
||||
}
|
||||
else {
|
||||
definition.getPropertyValues().addPropertyValue("order", new Integer(Integer.MAX_VALUE));
|
||||
}
|
||||
}
|
||||
list.add(definition);
|
||||
}
|
||||
Collections.sort(list, new OrderComparator());
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
private int getOrder(Class clazz) {
|
||||
if (clazz.getName().equals(TokenBasedRememberMeServices.class.getName())) {
|
||||
return 100;
|
||||
|
||||
+14
-6
@@ -3,19 +3,27 @@
|
||||
*/
|
||||
package org.acegisecurity.config;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.acegisecurity.ui.logout.LogoutHandler;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @author vpuri
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class LogoutFilterBeanDefinitionParserTests extends TestCase {
|
||||
|
||||
public void testLogoutFilter(){
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("org/acegisecurity/config/logout-filter-with-handlers.xml");
|
||||
|
||||
public void testLogoutFilter() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/acegisecurity/config/logout-filter-with-handlers.xml");
|
||||
ConfigurableListableBeanFactory bf = (ConfigurableListableBeanFactory) context.getAutowireCapableBeanFactory();
|
||||
Map m = bf.getBeansOfType(LogoutHandler.class);
|
||||
assertEquals(2, m.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,11 +14,14 @@ http://www.springframework.org/schema/security http://www.springframework.org/sc
|
||||
<!-- If LogoutFilter does not have setHandlers populated, introspect app ctx for LogoutHandlers, using Ordered (if present, otherwise assume Integer.MAX_VALUE) -->
|
||||
<!-- The logoutUrl and redirectAfterLogout are both optional and default to that shown -->
|
||||
<security:logout-support id="logoutFilter"
|
||||
redirectAfterLogoutUrl="/" logoutUrl="/logout"/>
|
||||
redirectAfterLogoutUrl="/" logoutUrl="/logout" />
|
||||
|
||||
<security:authentication-remember-me-services
|
||||
id="rememberMeServices" key="someValue" />
|
||||
|
||||
<bean id="SecurityContextLogoutHandler"
|
||||
class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler" />
|
||||
|
||||
<security:principal-repository id="userDetailsService">
|
||||
<security:user-definition username="vishal"
|
||||
password="nottellingya" enabled="true">
|
||||
|
||||
Reference in New Issue
Block a user