5
我想在我的管理会话bean,以确保方法的具体作用"ROLE_ADMIN"
春季安全:方法不具有@PreAuthorize注解控制
配置(的applicationContext-security.xml文件):
<global-method-security pre-post-annotations="enabled" jsr250-annotations="enabled" secured-annotations="enabled"/>
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/**" access="isAuthenticated()"/>
<intercept-url pattern="/**" access="permitAll()"/>
<form-login
login-processing-url="/j_spring_security_check"
login-page="/login.jsf"
default-target-url="/main.jsf"
authentication-failure-url="/login.jsf" />
<session-management>
<concurrency-control max-sessions="1" error-if-maximum-exceeded="false" />
</session-management>
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" />
<user name="user1" password="user1" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<beans:bean id="loggerListener" class="org.springframework.security.authentication.event.LoggerListener"/>
bean的担保方式:
@PreAuthorize("hasRole('ROLE_ADMIN')")
public String buy() {
...
}
当我登录下user1
或anonym
,然后点击“购买”按钮上的基于web页面,它仍然重定向到下一页。
我想到的是发生了一些拒绝访问异常,它没有。
实际尝试过,它是一样的。据我所知,安全注释的立场,例如,对于@Secured注释,我根本不使用。我使用预先注释@PreAuthorize – sergionni 2011-02-16 21:51:41