Announcement Announcement Module
Collapse
No announcement yet.
Spring security integration issues with flex Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring security integration issues with flex

    Hi,
    I am trying to integrate flex and spring security. But i am having issues with loading the context itself.

    here is the error that it get:
    Code:
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerLoginCommand': Cannot resolve reference to bean '_authenticationManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_authenticationManager': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No authentication providers were found in the application context
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
    	at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:479)
    	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:162)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:835)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
    	... 68 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_authenticationManager': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No authentication providers were found in the application context
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
    	... 83 more
    Caused by: java.lang.IllegalArgumentException: No authentication providers were found in the application context
    	at org.springframework.util.Assert.notEmpty(Assert.java:268)
    	at org.springframework.security.config.NamespaceAuthenticationManager.afterPropertiesSet(NamespaceAuthenticationManager.java:31)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    	... 93 more
    Here is my web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    
    <web-app>
        <display-name>BlazeDS Samples</display-name>
        <description>BlazeDS Sample Application</description>
    
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>
    			/WEB-INF/spring/*-context.xml
    		</param-value>
    	</context-param>
    
        <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>
    	
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    	
    	<servlet>
    		<servlet-name>samples</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    
    	<servlet-mapping>
        	<servlet-name>samples</servlet-name>
        	<url-pattern>/messagebroker/*</url-pattern>
     	</servlet-mapping>
    
    </web-app>
    here is my security-context.xml
    [CODE]<?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">

    <http auto-config="true"/>

    <authentication-provider>
    <user-service>
    <user name="john" password="john" authorities="ROLE_USER, ROLE_ADMIN" />
    <user name="guest" password="guest" authorities="ROLE_GUEST" />
    </user-service>
    </authentication-provider>

    </beans:beans>[CODE]

    here is the sample-servlet.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:flex="http://www.springframework.org/schema/flex"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    		xmlns:context="http://www.springframework.org/schema/context"
    		xmlns:security="http://www.springframework.org/schema/security"
    	xsi:schemaLocation="
    		http://www.springframework.org/schema/beans
    		http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    		http://www.springframework.org/schema/flex 
    		http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
    		http://www.springframework.org/schema/security
    		http://www.springframework.org/schema/security/spring-security-2.0.4.xsd
    		http://www.springframework.org/schema/context
    		http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    		
    	<flex:message-broker>
    		<flex:message-service
    			default-channels="my-amf,my-streaming-amf,my-longpolling-amf,my-polling-amf" />
    		<flex:secured >
    		
    		</flex:secured>
    	</flex:message-broker>
    
    	
    
    	
    	<context:annotation-config />
    	<context:component-scan base-package="flex.samples" />
    
    	<!-- Expose the productService bean for BlazeDS remoting -->
    	<flex:remoting-destination ref="product" channels="my-amf"/>
    
    	<!-- Expose the contactService bean for BlazeDS remoting -->
    	<!-- flex:remoting-destination ref="chat-room-service" /-->
    
    	<!-- Expost the securedProductService bean for BlazeDS remoting -->
    	<!-- flex:remoting-destination ref="census" /-->
    	<!-- flex:remoting-destination ref="flex-client-qos-config" channels="per-client-qos-polling-amf"/-->
    	
    	
    	<flex:message-destination id="feed"/>
    	<flex:message-destination id="chat"/>
    	<flex:message-destination id="dashboard"/>
    	<flex:message-destination id="market-data-feed" allow-subtopics="true" subtopic-separator="." channels="my-polling-amf,my-streaming-amf,per-client-qos-polling-amf"/>
    
    	<bean id="product" class="flex.samples.product.ProductService">
    		<security:intercept-methods>
    			<security:protect method="get*,create*,update*,remove*,delete*" access="ROLE_USER" />
    		</security:intercept-methods>
    	</bean>
    
    </beans>
    I am not sure what could be the error... Can somebody help please?

  • #2
    Looks like a problem with your Spring Security setup, though I'm not spotting it immediately. Are you able to start the app okay without the DispatcherServlet? What container are you using? Are you certain the ContextLoaderListener is initializing before the servlet?

    Comment


    • #3
      if you read spring blazeDs's doc, you'll find they use <preauthentication......>, rather than
      <http auto-config=true>

      Comment

      Working...
      X