Hy. 내가하려고하는 것은 Spring 보안을 Jsf + Spring IOC + Hibernate 응용 프로그램과 통합하는 것이다. 로그인 페이지를 설정하고 다른 페이지를 필터링 할 수 있었다. 그렇게까지 좋았지 만, @Secured 또는 @PreAuthorize 주석을 managedBeans 내부의 메소드에 사용합니다 (Dao의 주석이 작동 함). 나는 아무 것도하지 않는다는 것을 깨달았습니다. 나는 포스 클래스 프록시가 필요하다는 것을 읽었다. Spring은 프록시 기반의 aop을 사용하고 관리되는 bean은 인터페이스를 구현하므로 클래스 프록시 대신 동적 프록시가 사용됩니다. 그래서 난 내 설정 파일에 이런 짓을 :스프링 보안 3.1 + JSF 2.0. ManagedBeans에서 주석을 달기에 문제가 있습니까?
<?xml version="1.0" encoding="UTF-8"?>
<!-- - Sample namespace-based configuration - - $Id: applicationContext-security.xml
3019 2008-05-01 17:51:48Z luke_t $ -->
<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-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<global-method-security secured-annotations="enabled" jsr250-annotations="enabled"/>
<http pattern="/css/**" security="none" />
<http pattern="/pages/login.xhtml" security="none" />
<http auto-config='false'>
<intercept-url pattern="/pages/customer/**" access='ROLE_SITE_ADMIN' />
<intercept-url pattern="/pages/department/overhead*" access='ROLE_SITE_ADMIN' />
<intercept-url pattern="/**"
access='ROLE_SITE_ADMIN,ROLE_PROJECT_MANAGER,ROLE_DEPARTMENT_MANAGER,ROLE_ACCOUNTING' />
<form-login login-page="/pages/login.xhtml"
default-target-url='/pages/reports.xhtml' always-use-default-target='true'
authentication-failure-handler-ref="userLoginService" />
<logout invalidate-session="true" logout-success-url="/pages/login.xhtml"/>
</http>
<authentication-manager>
<authentication-provider user-service-ref='userLoginService'>
<password-encoder hash="md5" />
</authentication-provider>
</authentication-manager>
<beans:bean id="userLoginService" class="com.evozon.demo.bean.SecureLoginService">
<beans:property name="defaultFailureUrl" value="/pages/login.xhtml" />
<beans:property name="userDao" ref="userDao" />
<beans:property name="loginReportDao" ref="loginReportDao" />
</beans:bean>
</beans:beans>
누군가가 주석이 관리 빈 내에서 작동하지 않는 이유는 내 말, 방법에 대한 수 :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"**
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<aop:aspectj-autoproxy proxy-target-class="true"/>
//the rest of the beans
</beans>
ApplicationContext에 보안 XML은 다음과 같습니다 문제를 해결 하시겠습니까? 예 :
@PreAuthorize("ROLE_PROJECT_MANAGER")
public void aproveVacation(Vacation vacation) {...}
들으 문제는 solved.The 해결되었습니다