zoukankan      html  css  js  c++  java
  • Shiro 安全管理器注入领域和缓存管理器为领域注入各种工具

    概要

    Realm是工兵角色,需要SecurityManager、CacheManager、Authenticator、Authorizer等

    CachingSecurityManager的注入之后

    public void setCacheManager(CacheManager cacheManager) {
        this.cacheManager = cacheManager;
        afterCacheManagerSet();
    }
    
    protected void afterCacheManagerSet() {
        applyEventBusToCacheManager();
    }

    RealmSecurityManager的注入之后

    public void setRealms(Collection<Realm> realms) {
        if (realms == null) {
            throw new IllegalArgumentException("Realms collection argument cannot be null.");
        }
        if (realms.isEmpty()) {
            throw new IllegalArgumentException("Realms collection argument cannot be empty.");
        }
        this.realms = realms;
        afterRealmsSet();
    }
    
    protected void afterRealmsSet() {
        applyCacheManagerToRealms();
        applyEventBusToRealms();
    }
    
    protected void applyCacheManagerToRealms() {
        CacheManager cacheManager = getCacheManager();
        Collection<Realm> realms = getRealms();
        if (cacheManager != null && realms != null && !realms.isEmpty()) {
            for (Realm realm : realms) {
                if (realm instanceof CacheManagerAware) {
                    ((CacheManagerAware) realm).setCacheManager(cacheManager);
                }
            }
        }
    }

    AuthenticatingSecurityManager注入之后

    protected void afterRealmsSet() {
        super.afterRealmsSet();
        if (this.authenticator instanceof ModularRealmAuthenticator) {
            ((ModularRealmAuthenticator) this.authenticator).setRealms(getRealms());
        }
    }

    AuthorizingSecurityManager注入之后

    protected void afterRealmsSet() {
        super.afterRealmsSet();
        if (this.authorizer instanceof ModularRealmAuthorizer) {
            ((ModularRealmAuthorizer) this.authorizer).setRealms(getRealms());
        }
    }
  • 相关阅读:
    Ajax三
    Ajax二
    【Verilog】组合逻辑写法
    【电路】LVDS 差分接口
    【C】数据类型定义
    【Flash】nv-ddr2接口Flash的ODT
    【vivado】clocking wizard 时钟配置
    【Linux】linux学习资料
    【Linux】ubuntu系统安装及软件依赖库
    【vivado】PL通过axi_hp接口控制PS的DDR
  • 原文地址:https://www.cnblogs.com/BINGJJFLY/p/9117194.html
Copyright © 2011-2022 走看看