正如我在问题标题中所说,我没有成功配置Spring Security……我已经关注了James Ward或Jettro Coenradie写的两篇文章,但我仍然没有!
首先,我试着让所有这些都在一个假项目中工作,它工作得很好,然后我在“真正的”项目中尝试了一下。关于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>首先,我尝试用注解@Secured("ROLE_USER")替换最后一段代码,但这并不起作用,这就是我使用security:intercept-methods和security:protect标记的原因。
在我的第一个伪项目中,当我启动我的flex应用程序(一个检索产品列表的简单数据网格)时,产品没有加载,并且我有一个分派的FaultEvent,所以Spring Security工作。
在第二个项目中,我在部署时遇到一个错误,告诉我"*“(或者当我尝试的时候是"findAll”)不是有效的方法名。
使用
<security:protect method="com.blablabla.UserService.findAll" access="ROLE_USER" />我不再有这个错误,我可以启动我的flex应用程序。
但是当我启动它时,我的所有用户(是的,在第二个应用程序中我检索用户,而不是产品)都加载到datagrid中!这意味着安全系统根本不起作用。
快把我逼疯了!
发布于 2010-08-08 12:22:09
我原本期望在<security:http>元素中看到一些<security:intercept-url>元素。
https://stackoverflow.com/questions/3415953
复制相似问题