初探Spring Security

remoting
 Provides intergration with Spring Remoting
 
web
 Contains filters and related web-security infrastructure code.Anything with a servlet API dependency.
 You’ll need it if you require Spring Security web authentication services and URL-based access-control.
 the main package is:
  org.springframework.security.web
 
config
 Contains the security namespace parsing code.You need it if you are using the Spring Security XML namespace for configuration.
 None of the classes are intended for direct use in an application.
 the main package is:
  org.springframework.security.config
  
LDAP
 LDAP authentication and provisioning code.Required if you need to use LDAP authentication or manage LDAP user entries.web

ACL
 Specialized domain object ACL implementation.Used to apply security to specific domain object instances within your application.spring

CAS
 Spring Security’s CAS client integration.If you want to use Spring Security web authentication with a CAS single sign-on server.
 
OpenID
 OpenID web authentication support. Used to authenticate users against an external OpenID server. express


http 配置
    http元素負責建立FilterChainProxy並過濾它使用的beans。一般filter預約義位置和不正確的filter順序將再也不是一個問題。


    屬性
        HTTP Security 配置容器,能夠定義多個元素,每一個封閉安全配置提供指定模式。
        也能夠經過設置"security"屬性爲"none"繞過spring security配置的過濾器。
        
        auto-config
            遺留屬性,自動註冊一個表單登陸,基本認證和logout URL和logout 服務。
            如未指定,默認false。咱們建議您避免使用這個,而顯式配置你須要的服務。
        entry-point-ref
            在ExceptionTranslationFilter上設置定製的AuthenticationEntryPoint。
        use-expressions
            在< intercept-url >元素的"access"屬性中可使用表達式,默認false。
            若啓用,每一個屬性應該包含一個表達式。若該表達式的值爲true,訪問將被受權。
        access-denied-page
            訪問拒絕時轉向的頁面,棄用access-denied-handler元素。
        servlet-api-provision
            提供的版本HttpServletRequest安全方法如isUserInRole()和getPrincipal()。
            經過訪問Spring SecurityContext實現。默認爲「true」。
    
    子元素
        custom-filter
            用來代表一個過濾器bean聲明應該被歸入安全過濾器鏈。
            
            before
                定製的filter應該放在鏈中哪一個一個以前。
                    - FIRST
                    - CHANNEL_FILTER
                    - SECURITY_CONTEXT_FILTER
                    - CONCURRENT_SESSION_FILTER
                    - WEB_ASYNC_MANAGER_FILTER
                    - HEADERS_FILTER
                    - CSRF_FILTER
                    - LOGOUT_FILTER
                    - X509_FILTER
                    - PRE_AUTH_FILTER
                    - CAS_FILTER
                    - FORM_LOGIN_FILTER
                    - OPENID_FILTER
                    - LOGIN_PAGE_FILTER
                    - DIGEST_AUTH_FILTER
                    - BASIC_AUTH_FILTER
                    - REQUEST_CACHE_FILTER
                    - SERVLET_API_SUPPORT_FILTER
                    - JAAS_API_SUPPORT_FILTER
                    - REMEMBER_ME_FILTER
                    - ANONYMOUS_FILTER
                    - SESSION_MANAGEMENT_FILTER
                    - EXCEPTION_TRANSLATION_FILTER
                    - FILTER_SECURITY_INTERCEPTOR
                    - SWITCH_USER_FILTER
                    - LAST
            position
                明確位置custom-filter應放置在鏈條。若是你是替換一個標準的過濾器。api

org.springframework.security.web.AuthenticationEntryPoint
    經過ExceptionTranslationFilter使用開始一個身份認證方案
    ExceptionTranslationFilter將填充AbstractAuthenticationProcessingFilter.SPRING_SECURITY_SAVED_REQUEST_KEY使用請求目標的URL到HttpSession在調用該方法前
    實現應該修改ServletResponse上的headers必要時開始認證處理
    
org.springframework.security.cas.web.CasAuthenticationEntryPoint
    經過ExceptionTranslationFilter使用開始一個身份認證經過JA-SIG Central Authentication Service(CAS)
    用戶瀏覽器將重定向到CAS登陸頁面,該頁面經過loginUrl指定,一旦登陸成功,該CAS登陸頁面將重定向頁面顯示經過service propertie
    service是一個http URL屬於當前的應用程序,該service URL由CasAuthenticationFilter監控及將驗證CAS登陸是否成功。
    
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
    抽象的處理器基於瀏覽器的基於http身份驗證請求
    該filter須要設置authenticationManager屬性,一個AuthenticationManager處理認證請求的tokens,由實現類建立。
    若請求匹配setRequiresAuthenticationRequestMatcher(RequestMatcher),該filter將攔截該請求並嘗試執行認證。
    認證由其子類實現的attemptAuthentication(HttpServletRequest, HttpServletResponse)方法實現
    
    認證成功
        若認證成功,其結果對象(Authentication)將置於當前線程的SecurityContext中,以保證由更早的filter完成建立。
        配置setAuthenticationSuccessHandler(AuthenticationSuccessHandler)將被調用,將重定向到適當的目的地成功後登陸。
        默認的行爲在SavedRequestAwareAuthenticationSuccessHandler實現,將利用任何DefaultSavedRequest設置經過ExceptionTranslationFilter和將用戶重定向到包含其中的URL。
        不然,它將重定向到webapp根"/"。經過注入一個該類不一樣的一個實現來定製該行爲,or使用不一樣的實現。
    
    認證失敗
        若認證失敗,它將委託到配置AuthenticationFailureHandler上,容許失敗的信息傳達到client上。
        默認實現SimpleUrlAuthenticationFailureHandler,發送401的錯誤碼到client,它也可使用一個失敗的URL進行配置,你能夠注入任何行爲須要在這裏。
    
    事件的發佈
        若是認證成功,一個InteractiveAuthenticationSuccessEvent經過application context發佈,若認證不成功,沒有事件發佈,由於這一般會被記錄由AuthenticationManager指定application event
    
    Session認證
        SessionAuthenticationStrategy一個可選,在一個成功調用attemptAuthentication方法後當即被調用
        不一樣的實現能夠注入,如防止固定session的攻擊or併發Session的數量
        
org.springframework.security.authentication.AuthenticationProvider
    代表一個類能處理一個指定org.springframework.security.core.Authentication的實現
    
org.springframework.security.core.userdetails.AuthenticationUserDetailsService
    容許基於一個Authentication對象檢索一個UserDetails對象
    
org.springframework.security.core.userdetails.UserDetailsService
    核心接口加載特定於用戶的數據,做爲整個框架的用戶DAO和由DaoAuthenticationProvider使用策略瀏覽器

org.springframework.security.core.GrantedAuthority
    代碼一個權力授予一個Authentication對象安全

org.springframework.security.access.intercept.AbstractSecurityInterceptor
 爲安全對象實現安全攔截的抽象類。該類將保證適當的啓動安全攔截的啓動配置,也實現了適當的安全對象調用,即:
 從SecurityContextHolder對象中得到Authentication對象
 若請求依賴一個安全or在SecurityMetadataSource對象上經過查找安全對象的請求一個公開調用
 做爲一個安全的調用
 若isAuthenticated返回false,或者alwaysReauthenticate是true,根據配置認證請求(AuthenticationManager),當認證後,使用返回的值替換SecurityContextHolder上的Authentication對象
 根據配置受權請求(AccessDecisionManager)
 執行任何run-as替換經過配置(RunAsManager)
 傳達控制到具體的子類,將使用執行對象進行具體處理。一個InterceptorStatusToken對象返回在子類完成處理以後,它的finally clause能保證AbstractSecurityInterceptor是可從新調用和正確使用finallyInvocation
 子類可從新調用AbstractSecurityInterceptor經過afterInvocation方法
 若RunAsManager取代Authentication對象,返回SecurityContextHolder到調用AuthenticationManager後已存在的對象
 若一個AfterInvocationManager定義,調用該調用管理並容許它替換對象將被返回給調用者
 控制再次返回到具體的子類,隨着被返回到調用者的對象,子類將原調用者返回的結果或異常
session

相關文章
相關標籤/搜索