mirror of
https://gitee.com/nutz/nutzboot.git
synced 2024-12-04 20:58:22 +08:00
fix: shiro支持多个realm
This commit is contained in:
parent
10c47be587
commit
16091acd4c
@ -1,6 +1,8 @@
|
||||
package org.nutz.boot.starter.shiro;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventListener;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.shiro.ShiroException;
|
||||
import org.apache.shiro.cache.CacheManager;
|
||||
@ -63,11 +65,15 @@ public class ShiroEnvStarter implements WebEventListenerFace {
|
||||
if (conf.getBoolean("shiro.session.enable", true)) {
|
||||
webSecurityManager.setSessionManager(ioc.get(WebSessionManager.class, "shiroWebSessionManager"));
|
||||
}
|
||||
String realmNames = conf.get("shiro.realm.names", "shiroRealm");
|
||||
String[] realms = StringUtils.split(realmNames, ',');
|
||||
for(String realm :realms) {
|
||||
if (ioc.has(realm))
|
||||
webSecurityManager.setRealm(ioc.get(Realm.class, realm));
|
||||
if (conf.has("shiro.realm.names")) {
|
||||
List<Realm> realms = new ArrayList<>();
|
||||
for (String realmName : StringUtils.split(conf.get("shiro.realm.names"), ',')) {
|
||||
realms.add(ioc.get(Realm.class, realmName));
|
||||
};
|
||||
webSecurityManager.setRealms(realms);
|
||||
}
|
||||
else if (conf.has("shiroRealm")) {
|
||||
webSecurityManager.setRealm(ioc.get(Realm.class, "shiroRealm"));
|
||||
}
|
||||
return webSecurityManager;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user