Spring Security 3 小記

一個典型的web應用驗證過程:

  1. 你訪問首頁,點擊一個鏈接。

  2. 向服務器發送一個請求,服務器判斷你是否在訪問一個受保護的資源。

  3. 如果你還沒有進行過認證,服務器發回一個響應,提示你必須進行認證。 響應可能是HTTP響應代碼,或者是重新定向到一個特定的web頁面。

  4. 依據驗證機制,你的瀏覽器將重定向到特定的web頁面,這樣你可以添加表單, 或者瀏覽器使用其他方式校驗你的身份(比如,一個基本校驗對話框,cookie,或者X509證書,或者其他)。

  5. 瀏覽器會發回一個響應給服務器。 這將是HTTP POST包含你填寫的表單內容,或者是HTTP頭部,包含你的驗證信息。

  6. 下一步,服務器會判斷當前的證書是否是有效的, 如果他們是有效的,下一步會執行。 如果他們是非法的,通常你的瀏覽器會再嘗試一次(所以你返回的步驟二)。

  7. 你發送的原始請求,會導致重新嘗試驗證過程。 有希望的是,你會通過驗證,得到豬狗的授權,訪問被保護的資源。 如果你有足夠的權限,請求會成功。否則,你會收到一個HTTP錯誤代碼403,意思是訪問被拒絕。



常用類

• SecurityContextHolder,to provide access to the SecurityContext.提供訪問SecurityContext的途徑

SecurityContext, to hold the Authentication and possibly request-specific security information.
Authentication, to represent the principal in a Spring Security-specific manner.
GrantedAuthority, to reflect the application-wide permissions granted to a principal.
UserDetails, to provide the necessary information to build an Authentication object from your application's DAOs or other source source of security data.
UserDetailsService, to create a UserDetails when passed in a String-based username (or certificate ID or the like).
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章