Shiro之UsernamePasswordTokenRememberMeAuthenticationTokenAuthenticationToken
繼承關系
先看一下三者的繼承關系,會有一個比較清楚的認識
AuthenticationToken
AuthenticationToken 用于收集用戶提交的身份(如用戶名)及憑據(如密碼)。Shiro會調用CredentialsMatcher對象的doCredentialsMatch方法對AuthenticationInfo對象和AuthenticationToken進行匹配。匹配成功則表示主體(Subject)認證成功,否則表示認證失敗。
RememberMeAuthenticationToken
它繼承自AuthenticationToken,可用在跨會話記住用戶身份。注意,當為相應的用戶創建新會話時,該用戶的身份將被記住,但不會被視為已通過身份驗證
UsernamePasswordToken
用于實現基于用戶名/密碼主體(Subject)身份認證。UsernamePasswordToken實現了 RememberMeAuthenticationToken 和 HostAuthenticationToken,可以實現“記住我”及“主機驗證”的支持。
總結
一般情況下UsernamePasswordToken已經可以滿足我們的大多數需求。當我們遇到需要聲明自己的Token類時,可以根據需求來實現AuthenticationToken,HostAuthenticationToken或RememberMeAuthenticationToken。
如果不需要“記住我”,也不需要“主機驗證”,則可以實現AuthenticationToken;
總結
以上是生活随笔為你收集整理的Shiro之UsernamePasswordTokenRememberMeAuthenticationTokenAuthenticationToken的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: rust(64)-指针类型(1)
- 下一篇: rust(65)-rust常用指针