Announcement Announcement Module
Collapse
No announcement yet.
setting up spring security for ldap Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • setting up spring security for ldap

    I'm setting up spring security with ldap for the first time (for both). I seem to be having some trouble getting DelegatingFilterProxy to instantiate. I'm looking for any ideas on how to solve this. I've tried importing the spring-security settings from a separate context file, but gone to plugging it into my application-context file.

    web.xml
    Code:
    <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>/WEB-INF/spring/root-context.xml</param-value>
    	</context-param>
    	
    	<!-- Creates the Spring Container shared by all Servlets and Filters -->
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    	
    	<!-- Spring Security -->
    	<filter>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<filter-class>
            	org.springframework.web.filter.DelegatingFilterProxy
          	</filter-class>
    	</filter>
     
    	<filter-mapping>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<url-pattern>/</url-pattern>
    	</filter-mapping>
    	
    
    	<!-- Processes application requests -->
    	<servlet>
    		<servlet-name>appServlet</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value>
    				/WEB-INF/spring/appServlet/servlet-context.xml
    			</param-value>
    		</init-param>
    		<!-- <load-on-startup>1</load-on-startup> -->
    	</servlet>
    	
    	<servlet-mapping>
    		<servlet-name>appServlet</servlet-name>
    		<url-pattern>/</url-pattern>
    	</servlet-mapping>
    servlet-context.xml
    Code:
    	<annotation-driven />
    
    
    	<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    	<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    	<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<beans:property name="prefix" value="/WEB-INF/views/" />
    		<beans:property name="suffix" value=".jsp" />
    	</beans:bean>
    
    	<context:component-scan base-package="com.americancentury.itsos" />
    
     	<beans:bean id="SurveyRep" class="com.americancentury.itsos.model.SurveyRep" autowire="constructor" />
    	<beans:bean id="SurveyTeamService" class="com.americancentury.itsos.model.SurveyTeamService" />
     	<beans:bean id="TeamActivityService" class="com.americancentury.itsos.model.TeamActivityService" />
     	<beans:bean id="ActivityTypeService" class="com.americancentury.itsos.model.ActivityTypeService" />
     	<beans:bean id="SurveyRepService" class="com.americancentury.itsos.model.SurveyRepService" />
     
    
    <!--   Spring Security Context -->
    	<sec:http auto-config="true">
    		<sec:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
    	</sec:http>
     
    	<sec:authentication-manager>
    	  <sec:authentication-provider ref="defaultAuthenticationProvider" />
    	  <!--  <sec:authentication-provider>
    	    <sec:user-service>
    			<sec:user name="admin" password="admin" authorities="ROLE_ADMIN" />
    	    </sec:user-service>
    	  </sec:authentication-provider> -->
    	</sec:authentication-manager>
     
     	<beans:bean id="defaultAuthenticationProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
            <beans:constructor-arg>  
      			<beans:bean class="org.springframework.security.ldap.authentication.BindAuthenticator">  
      				<beans:constructor-arg ref="ssContextSource"/>  
    				<beans:property name="userSearch" ref="userSearch" />
                </beans:bean>
            </beans:constructor-arg>  
      
            <beans:constructor-arg ref="defaultLdapAuthoritiesPopulator" />
        </beans:bean>
        
    	<!-- ******************************* -->
    	<!-- ldap setup for active directory -->
    	<!-- ******************************* -->
    	
    	<beans:bean id="ssContextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">  
     		<beans:constructor-arg value="server/DC=acslan,DC=ac,DC=ac,DC=com?sAMAccountName?sub?(objectClass=*)" />  
      		<beans:property name="userDn" value="CN=LDAP,CN=Users,DC=ac,DC=ac,DC=ac,DC=com"/>  
     </beans:bean>  
      
        <beans:bean id="defaultLdapAuthoritiesPopulator" class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">  
     		<beans:constructor-arg ref="ssContextSource" />
          	<beans:constructor-arg value="" />
          	<beans:property name="rolePrefix" value="ROLE_"/>
          	<beans:property name="searchSubtree" value="true"/>
          	<beans:property name="convertToUpperCase" value="false"/>
          	<beans:property name="ignorePartialResultException" value="true" />
       	</beans:bean>
        
        <beans:bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">  
      		<beans:constructor-arg index="0" value=""/>  
      		<beans:constructor-arg index="1" value="(&(sAMAccountName={0})(objectclass=user))"/>  
      		<beans:constructor-arg index="2" ref="ssContextSource" /> 
       	</beans:bean>
       
    <!--  End Spring Security -->
    Stacktrace
    INFO : org.springframework.beans.factory.xml.XmlBeanDefin itionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root-context.xml]
    INFO : org.springframework.beans.factory.support.DefaultL istableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@457d21: defining beans []; root of factory hierarchy
    INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 625 ms
    Dec 13, 2011 8:27:47 PM org.apache.catalina.core.StandardContext filterStart
    SEVERE: Exception starting filter springSecurityFilterChain
    org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'springSecurityFilterChain' is defined
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:527)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedLocalBeanDefinition(AbstractB eanFactory.java:1083)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:274 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:1079)
    at org.springframework.web.filter.DelegatingFilterPro xy.initDelegate(DelegatingFilterProxy.java:217)
    at org.springframework.web.filter.DelegatingFilterPro xy.initFilterBean(DelegatingFilterProxy.java:145)
    at org.springframework.web.filter.GenericFilterBean.i nit(GenericFilterBean.java:179)
    at org.apache.catalina.core.ApplicationFilterConfig.i nitFilter(ApplicationFilterConfig.java:273)
    at org.apache.catalina.core.ApplicationFilterConfig.g etFilter(ApplicationFilterConfig.java:254)
    at org.apache.catalina.core.ApplicationFilterConfig.s etFilterDef(ApplicationFilterConfig.java:372)
    at org.apache.catalina.core.ApplicationFilterConfig.< init>(ApplicationFilterConfig.java:98)
    at org.apache.catalina.core.StandardContext.filterSta rt(StandardContext.java:4584)
    at org.apache.catalina.core.StandardContext$2.call(St andardContext.java:5262)
    at org.apache.catalina.core.StandardContext$2.call(St andardContext.java:5257)
    at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.jav a:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    INFO : org.springframework.web.context.support.XmlWebAppl icationContext - Closing Root WebApplicationContext: startup date [Tue Dec 13 20:27:46 CST 2011]; root of context hierarchy
    INFO : org.springframework.beans.factory.support.DefaultL istableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@457d21: defining beans []; root of factory hierarchy
    Dec 13, 2011 8:27:47 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error filterStart
Working...
X