Spring Security受權 AccessDecisionManager

在前面那篇博客有一段配置: 
Xml代碼   收藏代碼
  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這個接口來實現。 

這個接口定義了這個方法: 
Java代碼   收藏代碼
  1. void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes)  
  2.     throws AccessDeniedException, InsufficientAuthenticationException;  
對應上面的配置:object就是url,configAttributes就是一個access。經常使用的實現類是AffirmativeBased 
相關文章
相關標籤/搜索