Shiro的標籤說明

-----------------標籤-------------------------------html

<shiro:guest>
	遊客訪問 <a href = "login.jsp"></a>
</shiro:guest>

user 標籤:用戶已經經過認證\記住我 登陸後顯示響應的內容
<shiro:user>
	歡迎[<shiro:principal/>]登陸 <a href = "logout">退出</a>
</shiro:user>

authenticated標籤:用戶身份驗證經過,即 Subjec.login 登陸成功 不是記住我登陸的
<shiro:authenticted>
	用戶[<shiro:principal/>] 已身份驗證經過
</shiro:authenticted>

notAuthenticated標籤:用戶未進行身份驗證,即沒有調用Subject.login進行登陸,包括"記住我"也屬於未進行身份驗證
<shiro:notAuthenticated>
	未身份驗證(包括"記住我")
</shiro:notAuthenticated>


principal 標籤:顯示用戶身份信息,默認調用
Subjec.getPrincipal()獲取,即Primary Principal
<shiro:principal property = "username"/>

hasRole標籤:若是當前Subject有角色將顯示body體內的內容
<shiro:hashRole name = "admin">
	用戶[<shiro:principal/>]擁有角色admin
</shiro:hashRole>

hasAnyRoles標籤:若是Subject有任意一個角色(或的關係)將顯示body體裏的內容
<shiro:hasAnyRoles name = "admin,user">
	用戶[<shiro:pricipal/>]擁有角色admin 或者 user
</shiro:hasAnyRoles>

lacksRole:若是當前 Subjec沒有角色將顯示body體內的內容
<shiro:lacksRole name = "admin">
	用戶[<shiro:pricipal/>]沒有角色admin
</shiro:lacksRole>

hashPermission:若是當前Subject有權限將顯示body體內容
<shiro:hashPermission name = "user:create">
	用戶[<shiro:pricipal/>] 擁有權限user:create
</shiro:hashPermission>

lacksPermission:若是當前Subject沒有權限將顯示body體內容
<shiro:lacksPermission name = "org:create">
	用戶[<shiro:pricipal/>] 沒有權限org:create
</shiro:lacksPermission>

  

---------------權限註解------------------------java

@RequiresAuthenthentication:表示當前Subject已經經過login進行身份驗證;即 Subjec.isAuthenticated()返回 true

@RequiresUser:表示當前Subject已經身份驗證或者經過記住我登陸的,

@RequiresGuest:表示當前Subject沒有身份驗證或者經過記住我登陸過,便是遊客身份

@RequiresRoles(value = {"admin","user"},logical = Logical.AND):表示當前Subject須要角色admin和user

@RequiresPermissions(value = {"user:delete","user:b"},logical = Logical.OR):表示當前Subject須要權限user:delete或者user:b
相關文章
相關標籤/搜索