本文整理匯總了Java中org.apache.shiro.web.mgt.DefaultWebSecurityManager.setSubjectFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultWebSecurityManager.setSubjectFactory方法的具體用法?Java DefaultWebSecurityManager.setSubjectFactory怎麽用?Java DefaultWebSecurityManager.setSubjectFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.shiro.web.mgt.DefaultWebSecurityManager
的用法示例。
在下文中一共展示了DefaultWebSecurityManager.setSubjectFactory方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: securityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入方法依賴的package包/類
@Bean(name = "securityManager")
@ConditionalOnMissingBean
public DefaultSecurityManager securityManager(CacheManager shiroCacheManager) {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
// 用自己的Factory實現替換默認
// 用於關閉session功能
dwsm.setSubjectFactory(new StatelessSubjectFactory());
dwsm.setSessionManager(defaultSessionManager());
// 關閉session存儲
((DefaultSessionStorageEvaluator) ((DefaultSubjectDAO)dwsm.getSubjectDAO()).getSessionStorageEvaluator()).setSessionStorageEnabled(false);
// <!-- 用戶授權/認證信息Cache, 采用EhCache 緩存 -->
dwsm.setCacheManager(shiroCacheManager);
SecurityUtils.setSecurityManager(dwsm);
return dwsm;
}
示例2: securityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入方法依賴的package包/類
@Bean
public DefaultWebSecurityManager securityManager() {
realms = realms == null ? new ArrayList<Realm>() : realms;
boolean existCasRealm = false;
for (Realm realm : realms) {
if (realm == casRealm()) {
existCasRealm = true;
break;
}
}
if (!existCasRealm) {
realms.add(0, casRealm());
}
DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
//authenticator必須在realm前麵設值,因為setRealm時會有條件的設置authenticator裏的realm
manager.setAuthenticator(authenticator());
manager.setSubjectFactory(casSubjectFactory());
manager.setCacheManager(securityCacheManager());
manager.setSessionManager(sessionManager());
manager.setRealms(realms);
return manager;
}
示例3: createSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入方法依賴的package包/類
private SecurityManager createSecurityManager() {
// create security manager
DefaultWebSecurityManager securityManager = /*new DefaultWebSecurityManager();/*/new JawnSecurityManager();
// add rememberme manager
securityManager.setSessionManager(new JawnSecuritySessionManager());//TODO
securityManager.setRememberMeManager(new JawnRememberMeManager());//TODO
securityManager.setSubjectFactory(new JWebSubjectFactory());//TODO
Collection<Realm> realms = readRealms();
// add realms to security manager
if (!realms.isEmpty())
applyRealmsToSecurityManager(realms, securityManager);
return securityManager;
}
示例4: getDefaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入方法依賴的package包/類
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager(MyShiroCasRealm myShiroCasRealm) {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
dwsm.setRealm(myShiroCasRealm);
// <!-- 用戶授權/認證信息Cache, 采用EhCache 緩存 -->
dwsm.setCacheManager(getEhCacheManager());
// 指定 SubjectFactory
dwsm.setSubjectFactory(new CasSubjectFactory());
return dwsm;
}
示例5: defaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入方法依賴的package包/類
@Bean(name = "securityManager")
public DefaultWebSecurityManager defaultWebSecurityManager(ShiroCasRealm realm){
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(realm);
// 指定SubjectFactory
securityManager.setSubjectFactory(new CasSubjectFactory());
securityManager.setSessionManager(this.sessionManager());
securityManager.setCacheManager(this.redisCacheManager());
return securityManager;
}
示例6: securityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入方法依賴的package包/類
/**
* shiro管理器
* @Description:TODO
* @author:hsj qq:2356899074
* @time:2017年12月11日 下午2:33:05
* @param pac4jRealm
* @param subjectFactory
* @return
*/
@Bean(name = "securityManager")
public DefaultWebSecurityManager securityManager(Realm pac4jRealm, SubjectFactory subjectFactory) {
DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
defaultWebSecurityManager.setRealm(pac4jRealm);
defaultWebSecurityManager.setSubjectFactory(subjectFactory);
return defaultWebSecurityManager;
}