使用shiro做安全驗證和授權管理
apache shiro 不依賴於spring spring security
目標: ssm+shiro
shiro的主要功能 1. 使用者認證 (登入) Authenticator 2. 授權 (使用者的訪問的控制)
shiro的架構組成 1. subject 認證的使用者 2. securitymanager 安全管理器 3. Authenticator 認證器 4. Authorizer 授權器 5. SessionManager 會話管理器 java web容器管理session c/s 管理session 6. SessionDao 對session資料的管理 7. Cachemanager 快取管理, 管理授權資料的快取管理 8. Realm 領域 儲存認證資料的模組 儲存認證的業務邏輯 可在授權的業務邏輯 -- 系統realm -- 自定義realm【重點】 9. cryptography 加密管理 MD5
*.ini 配置檔案 -- [users] 使用者列表 -- [main] -- [roles]
認證失敗: -- 帳號錯誤:org.apache.shiro.authc.UnknownAccountException -- 密碼錯誤:org.apache.shiro.authc.IncorrectCredentialsException
自定義Realm
MD5 不可逆 "窮舉法"
login.jsp (login.action) ---> FormAuthenticationFilter(authc)做使用者認證 ---> 獲取username和password ----> 呼叫Realm做認證 -------------------------------------------------------------------------------------------- select* from sys_permission where type = 'permission' and id in (select sys_permission_id from sys_role_permission where sys_role_id in ( select sys_role_id from sys_user_role where sys_user_id ='zhangsan' ))