本文整理匯總了Java中org.apache.shiro.web.mgt.DefaultWebSecurityManager類的典型用法代碼示例。如果您正苦於以下問題:Java DefaultWebSecurityManager類的具體用法?Java DefaultWebSecurityManager怎麽用?Java DefaultWebSecurityManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DefaultWebSecurityManager類屬於org.apache.shiro.web.mgt包,在下文中一共展示了DefaultWebSecurityManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getShiroFilterFactoryBean
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
/**
* ShiroFilter<br/>
* 注意這裏參數中的 StudentService 和 IScoreDao 隻是一個例子,因為我們在這裏可以用這樣的方式獲取到相關訪問數據庫的對象,
* 然後讀取數據庫相關配置,配置到 shiroFilterFactoryBean 的訪問規則中。實際項目中,請使用自己的Service來處理業務邏輯。
*
* @param securityManager
* @param casFilter
* @param userDao
* @return
* @author SHANHY
* @create 2016年1月14日
*/
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultWebSecurityManager securityManager, CasFilter casFilter, UserDao userDao) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
// 必須設置 SecurityManager
shiroFilterFactoryBean.setSecurityManager(securityManager);
// 如果不設置默認會自動尋找Web工程根目錄下的"/login.jsp"頁麵
shiroFilterFactoryBean.setLoginUrl(loginUrl);
// 登錄成功後要跳轉的連接
shiroFilterFactoryBean.setSuccessUrl(loginSuccessUrl);
shiroFilterFactoryBean.setUnauthorizedUrl(unauthorizedUrl);
// 添加casFilter到shiroFilter中
Map<String, Filter> filters = new HashMap<>();
filters.put("casFilter", casFilter);
// filters.put("logout",logoutFilter());
shiroFilterFactoryBean.setFilters(filters);
loadShiroFilterChain(shiroFilterFactoryBean, userDao);
return shiroFilterFactoryBean;
}
示例2: getShiroFilterFactoryBean
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultWebSecurityManager securityManager) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean
.setSecurityManager(securityManager);
shiroFilterFactoryBean.setLoginUrl("/login");
shiroFilterFactoryBean.setSuccessUrl("/");
filterChainDefinitionMap.put("/login", "authc");
filterChainDefinitionMap.put("/logout", "logout");
filterChainDefinitionMap.put("/static/**", "anon");
filterChainDefinitionMap.put("/api/**", "anon");
filterChainDefinitionMap.put("/register/**", "anon");
filterChainDefinitionMap.put("/admin/**", "roles[admin]");
filterChainDefinitionMap.put("/**", "user");
shiroFilterFactoryBean
.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}
示例3: shiroFilterFactoryBean
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
/**
* 對過濾器進行調整
*
* @param securityManager
* @return
*/
@Bean(name = "shiroFilter")
protected ShiroFilterFactoryBean shiroFilterFactoryBean(DefaultWebSecurityManager securityManager, Config config) {
ShiroFilterFactoryBean filterFactoryBean = super.shiroFilterFactoryBean();
filterFactoryBean.setSecurityManager(securityManager);
//過濾器設置
Map<String, Filter> filters = new HashMap<>();
SecurityFilter securityFilter = new SecurityFilter();
securityFilter.setClients("cas,rest,jwt");
securityFilter.setConfig(config);
filters.put("casSecurityFilter", securityFilter);
CallbackFilter callbackFilter = new CallbackFilter();
callbackFilter.setConfig(config);
filters.put("callbackFilter", callbackFilter);
filterFactoryBean.setFilters(filters);
return filterFactoryBean;
}
示例4: getManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
@Bean("securityManager")
public DefaultWebSecurityManager getManager(Realm realm) {
DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
manager.setRealm(realm);
DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
DefaultSessionStorageEvaluator evaluator = new DefaultSessionStorageEvaluator();
evaluator.setSessionStorageEnabled(false);
subjectDAO.setSessionStorageEvaluator(evaluator);
manager.setSubjectDAO(subjectDAO);
return manager;
}
示例5: getShiroFilterFactoryBean
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean getShiroFilterFactoryBean(
DefaultWebSecurityManager securityManager,
FormAuthenticationFilter formAuthenticationFilter) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
// 必須設置 SecurityManager
shiroFilterFactoryBean.setSecurityManager(securityManager);
// 如果不設置默認會自動尋找Web工程根目錄下的"/login.jsp"頁麵
shiroFilterFactoryBean.setLoginUrl("/oss/login");
// 登錄成功後要跳轉的連接
shiroFilterFactoryBean.setSuccessUrl("/admin/index");
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
Map map=new HashMap<>();
// map.put("authc",formAuthenticationFilter);
shiroFilterFactoryBean.setFilters(map);
loadShiroFilterChain(shiroFilterFactoryBean);
return shiroFilterFactoryBean;
}
示例6: 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;
}
示例7: getShiroFilterFactoryBean
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
/**
* ShiroFilter<br/>
* 注意這裏參數中的 StudentService 和 IScoreDao 隻是一個例子,因為我們在這裏可以用這樣的方式獲取到相關訪問數據庫的對象,
* 然後讀取數據庫相關配置,配置到 shiroFilterFactoryBean 的訪問規則中。實際項目中,請使用自己的Service來處理業務邏輯。
*
* @param myShiroRealm
* @param stuService
* @param scoreDao
* @return
* @author SHANHY
* @create 2016年1月14日
*/
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultWebSecurityManager securityManager, StudentService stuService,UserDao userDao) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
// 必須設置 SecurityManager
shiroFilterFactoryBean.setSecurityManager(securityManager);
// 如果不設置默認會自動尋找Web工程根目錄下的"/login.jsp"頁麵
shiroFilterFactoryBean.setLoginUrl("/login");
// 登錄成功後要跳轉的連接
shiroFilterFactoryBean.setSuccessUrl("/user");
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
loadShiroFilterChain(shiroFilterFactoryBean, stuService, userDao);
return shiroFilterFactoryBean;
}
示例8: getShiroFilterFactoryBean
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
/**
* ShiroFilter<br/>
* 注意這裏參數中的 StudentService 和 IScoreDao 隻是一個例子,因為我們在這裏可以用這樣的方式獲取到相關訪問數據庫的對象,
* 然後讀取數據庫相關配置,配置到 shiroFilterFactoryBean 的訪問規則中。實際項目中,請使用自己的Service來處理業務邏輯。
*
* @param myShiroRealm
* @param stuService
* @param scoreDao
* @return
* @author SHANHY
* @create 2016年1月14日
*/
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean getShiroFilterFactoryBean(
DefaultWebSecurityManager securityManager,
StudentService stuService, UserDao userDao) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
// 必須設置 SecurityManager
shiroFilterFactoryBean.setSecurityManager(securityManager);
// 如果不設置默認會自動尋找Web工程根目錄下的"/login.jsp"頁麵
shiroFilterFactoryBean.setLoginUrl("/login");
// 登錄成功後要跳轉的連接
shiroFilterFactoryBean.setSuccessUrl("/user");
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
// shiroFilterFactoryBean.setFilters(filters);
loadShiroFilterChain(shiroFilterFactoryBean, stuService, userDao);
return shiroFilterFactoryBean;
}
示例9: 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;
}
示例10: createSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
/**
* Creates the security manager without registering it.
*
* @param repo the component repository, only used to register secondary items like lifecycle, not null
* @param pwService the password service, not null
* @return the security manager, not null
*/
protected SecurityManager createSecurityManager(ComponentRepository repo, PasswordService pwService) throws IOException {
// password matcher
PasswordMatcher pwMatcher = new PasswordMatcher();
pwMatcher.setPasswordService(pwService);
// user database realm
UserSource userSource = getUserSource();
if (userSource == null) {
userSource = getUserMaster();
}
UserSourceRealm realm = new UserSourceRealm(userSource);
realm.setAuthenticationCachingEnabled(true);
realm.setAuthorizationCachingEnabled(true);
realm.setCredentialsMatcher(pwMatcher);
realm.setPermissionResolver(AuthUtils.getPermissionResolver());
// security manager
DefaultWebSecurityManager sm = new DefaultWebSecurityManager();
sm.setRealm(realm);
sm.setAuthorizer(realm); // replace ModularRealmAuthorizer as not needed
sm.setCacheManager(new MemoryConstrainedCacheManager());
return sm;
}
示例11: 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;
}
示例12: createFilter
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
/**
* Create the Shiro filter. Overriding this method allows for complete customization of how Shiro is initialized.
*/
protected Filter createFilter(final T configuration) {
ShiroConfiguration shiroConfig = narrow(configuration);
final IniWebEnvironment shiroEnv = new IniWebEnvironment();
shiroEnv.setConfigLocations(shiroConfig.iniConfigs());
shiroEnv.init();
AbstractShiroFilter shiroFilter = new AbstractShiroFilter() {
@Override
public void init() throws Exception {
Collection<Realm> realms = createRealms(configuration);
WebSecurityManager securityManager = realms.isEmpty()
? shiroEnv.getWebSecurityManager()
: new DefaultWebSecurityManager(realms);
setSecurityManager(securityManager);
setFilterChainResolver(shiroEnv.getFilterChainResolver());
}
};
return shiroFilter;
}
示例13: 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;
}
示例14: defaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
@Bean(name = "securityManager")
public DefaultWebSecurityManager defaultWebSecurityManager(@Qualifier("shiroRealm") ShiroRealm realm){
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(realm);
// 指定SubjectFactory
securityManager.setSessionManager(this.sessionManager());
securityManager.setCacheManager(this.redisCacheManager());
return securityManager;
}
示例15: shiroFilterFactoryBean
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入依賴的package包/類
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean shiroFilterFactoryBean(DefaultWebSecurityManager securityManager){
ShiroFilterFactoryBean factoryBean = new MyShiroFilterFactoryBean();
factoryBean.setSecurityManager(securityManager);
factoryBean.setLoginUrl("/restlogin");
factoryBean.setSuccessUrl("/user");
factoryBean.setUnauthorizedUrl("/403");
loadShiroFilterChain(factoryBean);
return factoryBean;
}