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


Java RealmSecurityManager类代码示例

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


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

示例1: getRealm

import org.apache.shiro.mgt.RealmSecurityManager; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T getRealm(Class<? extends Realm> realmType){
	RealmSecurityManager securityManager = (RealmSecurityManager) SecurityUtils.getSecurityManager();
	if(!CollectionUtils.isEmpty(securityManager.getRealms())){
		for(Iterator<Realm> it = securityManager.getRealms().iterator(); it.hasNext();){
			Realm realm = it.next();
			if(realm.getClass().equals(realmType)){
				return (T) realm;
			}
		}
	}
	return null;
}
 
开发者ID:penggle,项目名称:xproject,代码行数:14,代码来源:ShiroUtils.java

示例2: 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

示例3: 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

示例4: clearCachedAuthorization

import org.apache.shiro.mgt.RealmSecurityManager; //导入依赖的package包/类
/**
 * clears the shiro authorization cache for this user -- call when
 * permissions change
 */
public void clearCachedAuthorization() {
	// cache clearing
	Collection crealms = ((RealmSecurityManager) SecurityUtils
			.getSecurityManager()).getRealms();
	Iterator cr = crealms.iterator();
	while (cr.hasNext()) {
		RoleSecurityJdbcRealm sm = (RoleSecurityJdbcRealm) cr.next();
		try {
			sm.clearCacheForPrincipalCollection(getSubject()
					.getPrincipals());
		} catch (Exception e) {
			// may happen if we call before login()
		}
	}
}
 
开发者ID:StarterInc,项目名称:Ignite,代码行数:20,代码来源:User.java

示例5: synchronizeRealms

import org.apache.shiro.mgt.RealmSecurityManager; //导入依赖的package包/类
/**
 * Synchronizes the realm's map with the security manager.
 */
protected final void synchronizeRealms() {
    RealmSecurityManager securityManager = (RealmSecurityManager)
            getSecurityManager();

    if (securityManager != null) {
        if (!realms.isEmpty()) {
            securityManager.setRealms(realms.values());
        } else {
            // bind simple realm because it should be at least one realm
            securityManager.setRealm(new SimpleAccountRealm());
        }
    } else {
        log.warn("Realm security manager is not available. Realms is not updated");
    }
}
 
开发者ID:panifex,项目名称:panifex-platform,代码行数:19,代码来源:ModularWebEnvironment.java

示例6: 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

示例7: assertRealmSecurityManager

import org.apache.shiro.mgt.RealmSecurityManager; //导入依赖的package包/类
private void assertRealmSecurityManager(SecurityManager securityManager) {
    if (securityManager == null) {
        throw new NullPointerException("securityManager instance cannot be null");
    }
    if (!(securityManager instanceof RealmSecurityManager)) {
        String msg = "securityManager instance is not a " + RealmSecurityManager.class.getName() +
                " instance.  This is required to access or configure realms on the instance.";
        throw new ConfigurationException(msg);
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:11,代码来源:IniSecurityManagerFactory.java

示例8: 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

示例9: 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

示例10: bindWebSecurityManager

import org.apache.shiro.mgt.RealmSecurityManager; //导入依赖的package包/类
@Override
protected void bindWebSecurityManager(final AnnotatedBindingBuilder<? super WebSecurityManager> bind) {
  bind(NexusWebSecurityManager.class).asEagerSingleton();

  // bind RealmSecurityManager and WebSecurityManager to _same_ component
  bind(RealmSecurityManager.class).to(NexusWebSecurityManager.class);
  bind.to(NexusWebSecurityManager.class);

  // bindings used by external modules
  expose(RealmSecurityManager.class);
  expose(WebSecurityManager.class);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:13,代码来源:WebSecurityModule.java

示例11: DefaultSecuritySystem

import org.apache.shiro.mgt.RealmSecurityManager; //导入依赖的package包/类
@Inject
public DefaultSecuritySystem(final EventManager eventManager,
                             final RealmSecurityManager realmSecurityManager,
                             final RealmManager realmManager,
                             final AnonymousManager anonymousManager,
                             final Map<String, AuthorizationManager> authorizationManagers,
                             final Map<String, UserManager> userManagers)
{
  this.eventManager = checkNotNull(eventManager);
  this.realmSecurityManager = checkNotNull(realmSecurityManager);
  this.realmManager = checkNotNull(realmManager);
  this.anonymousManager = checkNotNull(anonymousManager);
  this.authorizationManagers = checkNotNull(authorizationManagers);
  this.userManagers = checkNotNull(userManagers);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:16,代码来源:DefaultSecuritySystem.java

示例12: RealmManagerImpl

import org.apache.shiro.mgt.RealmSecurityManager; //导入依赖的package包/类
@Inject
public RealmManagerImpl(final EventManager eventManager,
                        final RealmConfigurationStore store,
                        @Named("initial") final Provider<RealmConfiguration> defaults,
                        final RealmSecurityManager realmSecurityManager,
                        final Map<String, Realm> availableRealms)
{
  this.eventManager = checkNotNull(eventManager);
  this.store = checkNotNull(store);
  log.debug("Store: {}", store);
  this.defaults = checkNotNull(defaults);
  log.debug("Defaults: {}", defaults);
  this.realmSecurityManager = checkNotNull(realmSecurityManager);
  this.availableRealms = checkNotNull(availableRealms);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:16,代码来源:RealmManagerImpl.java

示例13: AuthorizingRealmImpl

import org.apache.shiro.mgt.RealmSecurityManager; //导入依赖的package包/类
@Inject
public AuthorizingRealmImpl(final RealmSecurityManager realmSecurityManager,
                            final UserManager userManager,
                            final Map<String, UserManager> userManagerMap)
{
  this.realmSecurityManager = realmSecurityManager;
  this.userManager = userManager;
  this.userManagerMap = userManagerMap;
  setCredentialsMatcher(new Sha1CredentialsMatcher());
  setName(NAME);
  setAuthenticationCachingEnabled(false); // we authz only, no authc done by this realm
  setAuthorizationCachingEnabled(true);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:14,代码来源:AuthorizingRealmImpl.java

示例14: getPortofinoRealm

import org.apache.shiro.mgt.RealmSecurityManager; //导入依赖的package包/类
public static PortofinoRealm getPortofinoRealm() {
    RealmSecurityManager realmSecurityManager =
            (RealmSecurityManager)SecurityUtils.getSecurityManager();
    PortofinoRealm portofinoRealm =
            (PortofinoRealm) realmSecurityManager.getRealms().iterator().next();
    return portofinoRealm;
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:8,代码来源:ShiroUtils.java

示例15: getRealm

import org.apache.shiro.mgt.RealmSecurityManager; //导入依赖的package包/类
protected Realm getRealm() {
    final SecurityManager securityManager = SecurityUtils.getSecurityManager();
    if(securityManager instanceof RealmSecurityManager) {
        Collection<Realm> realms = ((RealmSecurityManager) securityManager).getRealms();
        if(!CollectionUtils.isEmpty(realms) && realms.size() == 1) {
            return realms.iterator().next();
        }
    }
    
    throw new MultiRealmException();
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:12,代码来源:RealmServiceImpl.java


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