use of org.apache.shiro.subject.SubjectContext in project nutzboot by nutzam.
the class ShiroEnvStarter method getWebSecurityManager.
@IocBean(name = "shiroWebSecurityManager")
public WebSecurityManager getWebSecurityManager() {
DefaultWebSecurityManager webSecurityManager = new DefaultWebSecurityManager() {
protected SubjectContext resolveSession(SubjectContext context) {
if (context.resolveSession() != null) {
return context;
}
try {
Session session = resolveContextSession(context);
if (session != null) {
context.setSession(session);
}
} catch (InvalidSessionException e) {
}
return context;
}
};
// Shiro Session相关
if (conf.getBoolean(PROP_SESSION_ENABLE, true)) {
webSecurityManager.setSessionManager(ioc.get(WebSessionManager.class, "shiroWebSessionManager"));
}
List<Realm> realms = new ArrayList<>();
for (String realmName : ioc.getNamesByType(Realm.class)) {
realms.add(ioc.get(Realm.class, realmName));
}
if (realms.size() > 0)
webSecurityManager.setRealms(realms);
webSecurityManager.setRememberMeManager(ioc.get(RememberMeManager.class, "shiroRememberMeManager"));
return webSecurityManager;
}
Aggregations