Announcement Announcement Module
Collapse
No announcement yet.
More than One Access Control Policy Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • More than One Access Control Policy

    Is it possible to have more than one access control policy? Such that the interceptor will check one policy for a particular username and password. If found then that username and password is authenticated. If not found the interceptor will check the other file for the given username and password.

    If there is such a way, how would I configure this?

  • #2
    Specify multiple providers on the ProviderManager (used for checking username/password). If you specify multiple it will be passed on to the next etc.

    Comment


    • #3
      Is this what you meant?

      Code:
      <bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
      		<property name="providers">
      			<list>
      				<ref local="daoAuthenticationProvider"/>
      				<ref local="daoAuthenticationProvider2"/>
      				<bean class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider">
      					<property name="key" value="changeThis"/>
      				</bean>
      				<bean class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider">
      					<property name="key" value="changeThis"/>
      				</bean>
      			</list>
      		</property>
      	</bean>
      
      	<bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
      		<property name="userDetailsService" ref="userDetailsService"/>
      		<property name="userCache">
      			<bean class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
      				<property name="cache">
      					<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
      						<property name="cacheManager">
      							<bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
      						</property>
      						<property name="cacheName" value="userCache"/>
      					</bean>
      				</property>
      			</bean>
      		</property>
      	</bean>
      	
      	<bean id="daoAuthenticationProvider2" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
      		<property name="userDetailsService2" ref="userDetailsService2"/>
      		<property name="userCache">
      			<bean class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
      				<property name="cache">
      					<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
      						<property name="cacheManager">
      							<bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
      						</property>
      						<property name="cacheName" value="userCache"/>
      					</bean>
      				</property>
      			</bean>
      		</property>
      	</bean>
      
      	<!-- UserDetailsService is the most commonly frequently Acegi Security interface implemented by end users -->
      	<bean id="userDetailsService" class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl">
      		<property name="userProperties">
      			<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
      				<property name="location" value="/WEB-INF/users.properties"/>
      			</bean>
      		</property>
      	</bean>
      	<bean id="userDetailsService2" class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl">
      		<property name="userProperties">
      			<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
      				<property name="location" value="/WEB-INF/users2.properties"/>
      			</bean>
      		</property>
      	</bean>
      I get the following error;

      Code:
      org.springframework.beans.NotWritablePropertyException: Invalid property 'userDetailsService2' of bean class [org.acegisecurity.providers.dao.DaoAuthenticationProvider]: Bean property 'userDetailsService2' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

      Comment


      • #4
        Ofcourse you get that error... The DaoAuthenticationProvider doesn't have a property called userDetailsService2. It should be userDetailsService as in your other provider, only the ref should be different!

        Comment


        • #5
          Originally posted by mdeinum View Post
          Ofcourse you get that error... The DaoAuthenticationProvider doesn't have a property called userDetailsService2. It should be userDetailsService as in your other provider, only the ref should be different!
          woops! Thanks, got it working now. Its amazing that after all this time its always the silly mistakes that stump me.

          Comment


          • #6
            Your welcome, glad it work.

            Regarding the mistakes, don't tell anyone but I think we all make them .

            Comment

            Working...
            X