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 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM