2010-08-05 57 views
1

正如我在我的问题的标题中说的,我没有成功配置Spring Security ... 我已经关注了两篇由James Ward或Jettro撰写的文章Coenradie,但我仍然没有它![ACEGI]错误或没有安全

首先,我试着让所有这些工作在一个假项目中,并且运行良好,因为我尝试了“真正的”项目。 Spring Security的配置文件完全一样,但真正的项目失败了。

我的配置 在web.xml:

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>/WEB-INF/config/applicationContext.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> 

    ... 

<servlet> 
    <servlet-name>Spring MVC Servlet Dispatcher</servlet-name> 
    <display-name>Spring MVC Servlet Dispatcher</display-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <init-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value>/WEB-INF/config/webApplicationContext.xml</param- value> 
     </init-param> 
    <load-on-startup>1</load-on-startup> 
</servlet> 

在applicationContext.xml中:

<security:global-method-security secured-annotations="enabled" jsr250-annotations="enabled" /> 

<security:http entry-point-ref="preAuthenticatedEntryPoint"> 
    <security:anonymous enabled="false"/> 
</security:http> 

<bean id="preAuthenticatedEntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/> 

<security:authentication-manager> 
    <security:authentication-provider> 
     <security:user-service> 
      <security:user name="arnaud" password="arnaud" authorities="ROLE_USER"/> 
     </security:user-service> 
    </security:authentication-provider> 
</security:authentication-manager> 

在webApplicationContext.xml CECI:

<flex:message-broker> 
    <flex:secured /> 
</flex:message-broker> 

而且在每一个bean服务:

<security:intercept-methods> 
    <security:protect method="*" access="ROLE_USER" /> 
</security:intercept-methods> 

首先,我尝试用annotations @Secured(“ROLE_USER”)代替最后一段代码,这没有起作用,这就是为什么我使用了security:intercept-methods和security:protect tags。

在我的第一个虚拟项目中,当我启动我的Flex应用程序(一个简单的数据网格检索产品列表)时,产品未加载并且我分派了一个FaultEvent,因此Spring Security可以工作。

在第二个项目中,真实的我在部署时发生错误,告诉我“*”(或者我试过的时候“findAll”)不是有效的方法名称。

随着

<security:protect method="com.blablabla.UserService.findAll" access="ROLE_USER" /> 

我不再有这个错误,我可以启动我的Flex应用程序。

但是,当我启动它时,我的所有用户(是的,在第二个应用程序中检索用户,而不是产品)都加载到数据网格中!这意味着安全性根本不起作用。

这让我疯狂!

+0

您使用的是什么版本的spring/spring-security? – ALOToverflow 2010-11-09 20:31:53

回答

0

我预计会在<security:http>元素中看到一些<security:intercept-url>元素。