Browse Source

SEC-271: removed registration of BFPP(RemeberMeServicesDependenciesConfigurer) as autodetection of dependencies is now handled in TokenBasedRememberMeServices

Vishal Puri 18 years ago
parent
commit
6c22fea917

+ 1 - 8
sandbox/spring-security-config/src/main/java/org/acegisecurity/config/RememberMeServicesBeanDefinitionParser.java

@@ -15,6 +15,7 @@ import org.springframework.util.StringUtils;
 import org.w3c.dom.Element;
 
 /**
+ * Parses 
  * @author vpuri
  *
  */
@@ -30,9 +31,6 @@ public class RememberMeServicesBeanDefinitionParser extends AbstractBeanDefiniti
 	 */
 	private static final String KEY = "key";
 
-	/**
-	 * 
-	 */
 	protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
 		Assert.notNull(parserContext, "ParserContext must not be null");		
 		
@@ -51,11 +49,6 @@ public class RememberMeServicesBeanDefinitionParser extends AbstractBeanDefiniti
 			rememberMeServicesBeanDef.getPropertyValues().addPropertyValue(USER_DETAILS_SERVICE_PROPERTY,
 					new RuntimeBeanReference(rememberMeServicesRef));
 		}  
-		else {
-			// register a bean definition parse
-			RootBeanDefinition configurer = new RootBeanDefinition(RemeberMeServicesDependenciesConfigurer.class);
-			parserContext.getReaderContext().registerWithGeneratedName(configurer);
-		}
 		return rememberMeServicesBeanDef;
 	}
 

+ 1 - 0
sandbox/spring-security-config/src/test/java/org/acegisecurity/config/RememberMeBeanDefinitionParserTest.java

@@ -7,6 +7,7 @@ import org.acegisecurity.providers.dao.DaoAuthenticationProvider;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
+//TODO: fix test name
 public class RememberMeBeanDefinitionParserTest extends TestCase {
 	
 	public void testParserDefaults() {

+ 62 - 0
sandbox/spring-security-config/src/test/resources/org/acegisecurity/config/remember-me-autodetect.xml

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:security="http://www.springframework.org/schema/security"
+	xmlns:util="http://www.springframework.org/schema/util"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
+	http://www.springframework.org/schema/util http://www.springframework.org/schema/beans/spring-util-2.0.xsd
+http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd">
+
+	<!-- http://www.springframework.org/schema/security file:/Users/vpuri/interface21/acegisecurity/trunk/acegisecurity/core/src/main/resources/org/acegisecurity/config/spring-security-2.0.xsd -->
+	<!-- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd" -->
+
+	<!-- ======================== AUTHENTICATION ======================= -->
+
+	<!-- makes the filter, but does little else, as it auto-detects everything -->
+	<security:authentication-remember-me-filter id="rememberMeFilter" />
+
+	<!-- services should auto-detect UserDetails from app ctx if principalRepository was not specified; -->
+	<!-- key is optional; if unspecified, in the NamespaceHandler pick a rnd int and use for all unspecified key properties for acegi beans -->
+	<security:authentication-remember-me-services
+		id="rememberMeServices" key="someValue" />
+
+	<!-- The rules are:
+		AuthenticationManager interface is implemented by ProviderManager
+		So if you have any auto-detection, create a ProviderManager definition
+		If ProviderManager.setProvider(List) is never called, auto-detect all AuthenticationProviders from app ctx, using Ordered to resolve their order
+		Every authentication mechanism OR provider must start with security:authentication-something
+		Use appropriate attrs and elements depending on provider or mechanism
+	-->
+	<!-- make it optional, if not supplied autodetect all auth-providers from app ctx, using Ordered to resolve their order  -->
+	<security:authentication-mechanism id="authenticationManager">
+		<security:authentication-jdbc ref="authenticationRepository" />
+	</security:authentication-mechanism>
+
+	<!-- dao authentication provider -->
+	<security:authentication-repository id="authenticationRepository" />
+
+	<bean id="userDetailsService"
+		class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">
+		<property name="dataSource">
+			<ref bean="dataSource" />
+		</property>
+	</bean>
+
+	<bean id="dataSource"
+		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+		<property name="driverClassName">
+			<value>org.hsqldb.jdbcDriver</value>
+		</property>
+		<property name="url">
+			<value>jdbc:hsqldb:mem:test</value>
+			<!-- <value>jdbc:hsqldb:hsql://localhost/acl</value> -->
+		</property>
+		<property name="username">
+			<value>sa</value>
+		</property>
+		<property name="password">
+			<value></value>
+		</property>
+	</bean>
+</beans>

+ 5 - 18
sandbox/spring-security-config/src/test/resources/org/acegisecurity/config/remember-me-defaults.xml

@@ -14,7 +14,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/sc
 	<!-- ======================== AUTHENTICATION ======================= -->
 
 	<!-- makes the filter, but does little else, as it auto-detects everything -->
-	<security:authentication-remember-me-filter id="rememberMeFilter" rememberMeServicesBeanRef="rememberMeServices" />
+	<security:authentication-remember-me-filter id="rememberMeFilter" />
 
 	<!-- services should auto-detect UserDetails from app ctx if principalRepository was not specified; -->
 	<!-- key is optional; if unspecified, in the NamespaceHandler pick a rnd int and use for all unspecified key properties for acegi beans -->
@@ -28,29 +28,16 @@ http://www.springframework.org/schema/security http://www.springframework.org/sc
 		If ProviderManager.setProvider(List) is never called, auto-detect all AuthenticationProviders from app ctx, using Ordered to resolve their order
 		Every authentication mechanism OR provider must start with security:authentication-something
 		Use appropriate attrs and elements depending on provider or mechanism
-		-->
+	-->
 	<!-- make it optional, if not supplied autodetect all auth-providers from app ctx, using Ordered to resolve their order  -->
-	<security:authentication-mechanism id="authenticationManager">	
-			<security:authentication-jdbc ref="authenticationRepository"/>			
+	<security:authentication-mechanism id="authenticationManager">
+		<security:authentication-jdbc ref="authenticationRepository" />
 	</security:authentication-mechanism>
 
-	
-	<!--<bean id="authenticationManager"
-		class="org.acegisecurity.providers.ProviderManager">
-		  
-		 <property name="providers">
-			<list>
-				<ref local="authenticationRepository" />
-			</list>
-		</property>
-	</bean>-->
-	
 	<!-- dao authentication provider -->
 	<security:authentication-repository id="authenticationRepository" />
-	
-
 
-	<bean id="userDetailsService" 
+	<bean id="userDetailsService"
 		class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">
 		<property name="dataSource">
 			<ref bean="dataSource" />