当前位置: 首页>>代码示例>>Java>>正文


Java RealmSecurityManager.getRealms方法代码示例

本文整理汇总了Java中org.apache.shiro.mgt.RealmSecurityManager.getRealms方法的典型用法代码示例。如果您正苦于以下问题:Java RealmSecurityManager.getRealms方法的具体用法?Java RealmSecurityManager.getRealms怎么用?Java RealmSecurityManager.getRealms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.shiro.mgt.RealmSecurityManager的用法示例。


在下文中一共展示了RealmSecurityManager.getRealms方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPrincipals

import org.apache.shiro.mgt.RealmSecurityManager; //导入方法依赖的package包/类
@Override
public PrincipalCollection getPrincipals() {
    RealmSecurityManager manager = (RealmSecurityManager) SecurityUtils.getSecurityManager();
    SimplePrincipalCollection ret = new SimplePrincipalCollection();
    for (Realm realm : manager.getRealms()) {
        /*
        if (realm instanceof ProfileRealm) {
            String email = token.getEmail();
            if (((ProfileRealm) realm).accountExists(email)) {
                ret.add(email, realm.getName());
            }
        }
        */
    }
    ret.add(token.getEmail(), bearerTokenAuthenticatingRealm.getName());
    return ret;
}
 
开发者ID:auslides,项目名称:stateless-shiro,代码行数:18,代码来源:BearerAuthenticationInfo.java

示例2: contextInitialized

import org.apache.shiro.mgt.RealmSecurityManager; //导入方法依赖的package包/类
@Override
public void contextInitialized( ServletContextEvent sce )
{
    configuration.refresh();
    ShiroIniConfiguration config = configuration.get();
    String iniResourcePath = config.iniResourcePath().get() == null ? "classpath:shiro.ini" : config.iniResourcePath().get();
    sce.getServletContext().setInitParameter( "shiroConfigLocations", iniResourcePath );
    WebEnvironment env = initEnvironment( sce.getServletContext() );

    if ( realmsRefs != null && realmsRefs.iterator().hasNext() ) {

        // Register Realms Services
        RealmSecurityManager realmSecurityManager = ( RealmSecurityManager ) env.getSecurityManager();
        Collection<Realm> iniRealms = new ArrayList<Realm>( realmSecurityManager.getRealms() );
        for ( ServiceReference<Realm> realmRef : realmsRefs ) {
            iniRealms.add( realmRef.get() );
            LOG.debug( "Realm Service '{}' registered!", realmRef.identity() );
        }
        realmSecurityManager.setRealms( iniRealms );

    }

}
 
开发者ID:apache,项目名称:polygene-java,代码行数:24,代码来源:EnvironmentLoaderService.java

示例3: isAutoApplyRealms

import org.apache.shiro.mgt.RealmSecurityManager; //导入方法依赖的package包/类
protected boolean isAutoApplyRealms(SecurityManager securityManager) {
    boolean autoApply = true;
    if (securityManager instanceof RealmSecurityManager) {
        //only apply realms if they haven't been explicitly set by the user:
        RealmSecurityManager realmSecurityManager = (RealmSecurityManager) securityManager;
        Collection<Realm> realms = realmSecurityManager.getRealms();
        if (!CollectionUtils.isEmpty(realms)) {
            log.info("Realms have been explicitly set on the SecurityManager instance - auto-setting of " +
                    "realms will not occur.");
            autoApply = false;
        }
    }
    return autoApply;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:15,代码来源:IniSecurityManagerFactory.java

示例4: createEnvironment

import org.apache.shiro.mgt.RealmSecurityManager; //导入方法依赖的package包/类
@Override
protected WebEnvironment createEnvironment(ServletContext sc) {
    WebEnvironment webEnvironment = super.createEnvironment(sc);
    RealmSecurityManager rsm = (RealmSecurityManager) webEnvironment.getSecurityManager();
    HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher(HASHING_ALGORITHM);
    hashedCredentialsMatcher.setStoredCredentialsHexEncoded(true);
    jpaRealm.setCredentialsMatcher(hashedCredentialsMatcher);      
    Collection<Realm> realms = rsm.getRealms();
    realms.add(jpaRealm);
    rsm.setRealms(realms);
    ((DefaultWebEnvironment) webEnvironment).setSecurityManager(rsm);
    return webEnvironment;
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:14,代码来源:CDIAwareShiroEnvironmentLoader.java

示例5: activateService

import org.apache.shiro.mgt.RealmSecurityManager; //导入方法依赖的package包/类
@Override
public void activateService()
        throws Exception
{
    configuration.refresh();
    ShiroIniConfiguration config = configuration.get();

    String iniResourcePath = config.iniResourcePath().get() == null
                             ? Shiro.DEFAULT_INI_RESOURCE_PATH
                             : config.iniResourcePath().get();

    setIni( Ini.fromResourcePath( iniResourcePath ) );
    securityManager = getInstance();

    if ( realmsRefs != null && realmsRefs.iterator().hasNext() ) {

        // Register Realms Services
        RealmSecurityManager realmSecurityManager = ( RealmSecurityManager ) securityManager;
        Collection<Realm> iniRealms = new ArrayList<>( realmSecurityManager.getRealms() );
        for ( ServiceReference<Realm> realmRef : realmsRefs ) {
            iniRealms.add( realmRef.get() );
            LOG.debug( "Realm Service '{}' registered!", realmRef.identity() );
        }
        realmSecurityManager.setRealms( iniRealms );

    }

    ThreadContext.bind( securityManager );
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:30,代码来源:IniSecurityManagerService.java

示例6: getIsisModuleSecurityRealm

import org.apache.shiro.mgt.RealmSecurityManager; //导入方法依赖的package包/类
public static IsisModuleSecurityRealm getIsisModuleSecurityRealm() {
    final RealmSecurityManager securityManager = getSecurityManager();
    final Collection<Realm> realms = securityManager.getRealms();
    for (Realm realm : realms) {
        if(realm instanceof IsisModuleSecurityRealm) {
            IsisModuleSecurityRealm imsr = (IsisModuleSecurityRealm) realm;
            return imsr;
        }
    }
    return null;
}
 
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:12,代码来源:ShiroUtils.java

示例7: contextInitialized

import org.apache.shiro.mgt.RealmSecurityManager; //导入方法依赖的package包/类
/**
 * @param sce used to get the SecurityManager that has the Realms
 */
@Override
public void contextInitialized(ServletContextEvent sce) {
    RealmSecurityManager rsm = getRealmSecurityManager(sce);
    for (Realm r : rsm.getRealms()) {
        if (r instanceof JdbiShiroRealm) {
            initializeRealm((JdbiShiroRealm) r);
            if (whichRealm == RealmSelector.FIRST) {
                break;
            }
        }
    }

}
 
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:17,代码来源:JdbiRealmLoaderListener.java

示例8: contextDestroyed

import org.apache.shiro.mgt.RealmSecurityManager; //导入方法依赖的package包/类
/**
 * When the app shuts down we close the UserDAOs on the JdbiShiroRealm instances we initialized.
 *
 * @param sce used to get the SecurityManager that has the Realms
 */
@Override
public void contextDestroyed(ServletContextEvent sce) {
    RealmSecurityManager rsm = getRealmSecurityManager(sce);
    for (Realm r : rsm.getRealms())
        if (r instanceof JdbiShiroRealm) {
            destroyRealm((JdbiShiroRealm) r);
            if (whichRealm == RealmSelector.FIRST) {
                break;
            }
        }
}
 
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:17,代码来源:JdbiRealmLoaderListener.java


注:本文中的org.apache.shiro.mgt.RealmSecurityManager.getRealms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。