免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

Shiro核心類有哪些-創新互聯

這篇文章主要講解了“Shiro核心類有哪些”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“Shiro核心類有哪些”吧!

專注于為中小企業提供網站設計制作、網站制作服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業和田縣免費做網站提供優質的服務。我們立足成都,凝聚了一批互聯網行業人才,有力地推動了成百上千家企業的穩健成長,幫助中小企業通過網站建設實現規模擴充和轉變。

一:SessionManager

1.簡介

Shiro提供了完整的會話管理功能,不依賴底層容器,JavaSE應用和JavaEE應用都可以使用。

SessionManager管理著應用中所有Subject的會話,包括會話的創建,維護,刪除,失效,驗證等工作。

2.SessionManager接口

Session start(SessionContext context); 基于指定的上下文初始化數據啟動新會話

Session getSession(SessionKey key) throws SessionException;

根據指定的SessionKey檢索會話,如果找不到則返回null。如果找到了會話,但會話但無效(已停止或已過期)則拋出SessionException異常。

3.AbstractSessionManager implements SessionManager

 public void setGlobalSessionTimeout(long globalSessionTimeout)

 設置全局Session的超時時間,默認為30分鐘。設置為負數表示永遠都不超時。

4.AbstractValidatingSessionManager extends AbstractNativeSessionManager

protected boolean sessionValidationSchedulerEnabled;

是否進行Session驗證

protected long sessionValidationInterval;

Session驗證的時間間隔,默認為一小時

5.public class DefaultSessionManager extends AbstractValidatingSessionManager

private boolean deleteInvalidSessions;

是否刪除無效的Session

6.public class DefaultWebSessionManager extends DefaultSessionManager

  private boolean sessionIdCookieEnabled;

  是否從Cookie中獲取sessionId

  private boolean sessionIdUrlRewritingEnabled;

二:AuthenticationToken

AuthenticationToken 用于收集用戶提交的身份(如用戶名)及憑據(如密碼)。Shiro會調用CredentialsMatcher對象的

doCredentialsMatch方法對AuthenticationInfo對象和AuthenticationToken進行匹配。匹配成功則表示主體(Subject)認證成功,否則表示認證失敗。

一般情況下UsernamePasswordToken已經可以滿足我們的大我數需求。當我們遇到需要聲明自己的Token類時,可以根據需求來實現AuthenticationToken,

HostAuthenticationToken或RememberMeAuthenticationToken。

三:Realm

Realm是安全驗證數據的數據源。

1.public interface Realm 

String getName();

boolean supports(AuthenticationToken token);

AuthenticationInfo getAuthenticationInfo(AuthenticationToken token) throws AuthenticationException;

四:Subject與SubjectFactory

1.public interface Subject

一個Subject代表著應用的一個用戶。

Object getPrincipal();

Subject的唯一標識,比如用戶名,用戶ID,手機號等

PrincipalCollection getPrincipals();

boolean isPermitted(String permission);

boolean isPermitted(Permission permission);

boolean[] isPermitted(String... permissions);

boolean[] isPermitted(List<Permission> permissions);

void checkPermission(String permission) throws AuthorizationException;

void checkRole(String roleIdentifier) throws AuthorizationException;

void login(AuthenticationToken token) throws AuthenticationException;

boolean isAuthenticated();

boolean isRemembered();

2.public interface WebSubject extends Subject, RequestPairSource

ServletRequest getServletRequest();

ServletResponse getServletResponse();

3.public class DelegatingSubject implements Subject

  protected PrincipalCollection principals;

  protected boolean authenticated;

  protected String host;

  protected Session session;

  protected boolean sessionCreationEnabled;

  protected transient SecurityManager securityManager;

4.public class WebDelegatingSubject extends DelegatingSubject implements WebSubject

5.public interface SubjectContext extends Map<String, Object>

SubjectContext 將構建Subject的所有屬性都組織到一起,然后傳遞給一個SubjectFactory,用于構成一個Subject.

6.public interface SubjectFactory

Subject createSubject(SubjectContext context);

創建Subject

7.public class DefaultSubjectFactory implements SubjectFactory

8.public class DefaultWebSubjectFactory extends DefaultSubjectFactory 

五:SecurityManager

1.public interface SecurityManager extends Authenticator, Authorizer, SessionManager

Subject login(Subject subject, AuthenticationToken authenticationToken) throws AuthenticationException;

登錄

void logout(Subject subject);

登出

Subject createSubject(SubjectContext context);

2.public abstract class CachingSecurityManager implements SecurityManager, Destroyable, CacheManagerAware, EventBusAware

   private CacheManager cacheManager;

   private EventBus eventBus;

3.public abstract class RealmSecurityManager extends CachingSecurityManager

 private Collection<Realm> realms;

權限集合realms

4.public abstract class AuthenticatingSecurityManager extends RealmSecurityManager

private Authenticator authenticator;

SecurityManager用于身份驗證操作的具體實例

5.public abstract class AuthorizingSecurityManager extends AuthenticatingSecurityManager

 private Authorizer authorizer;

SecurityManager用于授權操作的具體實例

6.public abstract class SessionsSecurityManager extends AuthorizingSecurityManager

 private SessionManager sessionManager;

SecurityManager用于管理所有Session的具體實例。

7.public class DefaultSecurityManager extends SessionsSecurityManager

    protected RememberMeManager rememberMeManager;

   記著引用中與當前Subject關聯的Seeion,免重新登錄

    protected SubjectDAO subjectDAO;

   Subject的持久化存儲

    protected SubjectFactory subjectFactory;

   創建應用Subject的工廠

8.public class DefaultWebSecurityManager extends DefaultSecurityManager implements WebSecurityManager

boolean isHttpSessionMode();

是否使用Servlet 容器的HttpSession

感謝各位的閱讀,以上就是“Shiro核心類有哪些”的內容了,經過本文的學習后,相信大家對Shiro核心類有哪些這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創新互聯,小編將為大家推送更多相關知識點的文章,歡迎關注!

網頁標題:Shiro核心類有哪些-創新互聯
本文鏈接:http://newbst.com/article6/dijgig.html

成都網站建設公司_創新互聯,為您提供網站營銷商城網站企業網站制作手機網站建設網站策劃自適應網站

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

小程序開發