Spring Security授权 AccessDecisionManager

在前面那篇博客有一段配置:
  1. <http auto-config="false" disable-url-rewriting="true" use-expressions="true" entry-point-ref="dtAuth"
  2. create-session="never">
  3. <!-- <session-management session-authentication-strategy-ref="dtsession"/> -->
  4. <intercept-url pattern="/unread/get" access="isAuthenticated()"/>
  5. <intercept-url pattern="/authtest.xhtm" access="hasRole('working')"/>
  6. <intercept-url pattern="/authtest1.xhtm" access="hasRole('trac')"/>
  7. <intercept-url pattern="/cmmt/uc" access="isAuthenticated()"/>
  8. <intercept-url pattern="/favicon.ico" access="denyAll"/>
  9. <intercept-url pattern="/**" access="permitAll"/>
  10. <custom-filter position="PRE_AUTH_FILTER" ref="dtSessionMgr"/>
  11. </http>

pattern表示url,access表示url的权限,但这个isAuthenticated()具体在哪里执行呢?原来Spring提供授权机制,由org.springframework.security.access.AccessDecisionManager这个接口来实现。 

这个接口定义了这个方法:

  1. void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes)
  2. throws AccessDeniedException, InsufficientAuthenticationException;

对应上面的配置:object就是url,configAttributes就是一个access。常用的实现类是AffirmativeBased 

上一篇:BZOJ 4127 Abs 解题报告


下一篇:JavaScript------入门