本文整理汇总了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;
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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 );
}
示例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;
}
示例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;
}
}
}
}
示例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;
}
}
}