1. 程式人生 > >shiro框架之二------架構元件

shiro框架之二------架構元件

官網:https://shiro.apache.org/


Shiro主要元件包括:Subject,SecurityManager,Authenticator,Authorizer,SessionManager,CacheManager,Cryptography,Realms。


1. Subject
Subject表示與系統互動的物件,可以是登入系統的操作使用者,也可能是另外一個軟體系統。
Subject類圖:

2. SecurityManager
SecurityManager是Shiro架構最核心的元件。實際上,SecurityManager就是Shiro框架的控制器,協調其他元件一起完成認證和授權,如下圖所示:

SecurityManager類圖:

3. Authenticator
Authenticator用於認證,協調一個或者多個Realm,從Realm指定的資料來源取得資料之後進行執行具體的認證。
見org.apache.shiro.authc.pam.ModularRealmAuthenticator原始碼:

Authenticator類圖:

4. Authorizer
Authorizer使用者訪問控制授權,決定使用者是否擁有執行指定操作的許可權。
見org.apache.shiro.authz.ModularRealmAuthorizer原始碼:

Authorizer類圖:

5. SessionManager
Shiro與生俱來就支援會話管理,這在安全類框架中都是獨一無二的功能。即便不存在web容器環境,shiro都可以使用自己的會話管理機制,提供相同的會話API。
SessionManager類圖:

6. CacheManager
快取元件,用於快取認證資訊等。
CacheManager類圖:

7. Cryptography
Shiro提供了一個加解密的命令列工具jar包,需要單獨下載使用。
詳見:https://shiro.apache.org/download.html

 

8. Realms
Realm定義了訪問資料的方式,用來連線不同的資料來源,如:LDAP,關係資料庫,配置檔案等等。
Realm類圖: