Java Code Examples for org.apache.shiro.web.mgt.DefaultWebSecurityManager#setRealm()

The following examples show how to use org.apache.shiro.web.mgt.DefaultWebSecurityManager#setRealm() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShiroConfig.java    From web-flash with MIT License 6 votes vote down vote up
@Bean("securityManager")
public DefaultWebSecurityManager getManager(ApiRealm realm) {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    // 使用自己的realm
    manager.setRealm(realm);

    /*
     * 关闭shiro自带的session,详情见文档
     * http://shiro.apache.org/session-management.html#SessionManagement-StatelessApplications%28Sessionless%29
     */
    DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
    DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
    defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
    subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
    manager.setSubjectDAO(subjectDAO);

    return manager;
}
 
Example 2
Source File: ShiroConfig.java    From flash-waimai with MIT License 6 votes vote down vote up
@Bean("securityManager")
public DefaultWebSecurityManager getManager(ApiRealm realm) {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    // 使用自己的realm
    manager.setRealm(realm);

    /*
     * 关闭shiro自带的session,详情见文档
     * http://shiro.apache.org/session-management.html#SessionManagement-StatelessApplications%28Sessionless%29
     */
    DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
    DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
    defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
    subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
    manager.setSubjectDAO(subjectDAO);

    return manager;
}
 
Example 3
Source File: ShiroConfiguration.java    From spring-boot-quickstart with Apache License 2.0 5 votes vote down vote up
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager(AuthorizingRealm realm) {
    DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
    dwsm.setRealm(realm);
    dwsm.setCacheManager(getEhCacheManager());
    return dwsm;
}
 
Example 4
Source File: ShiroConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
/**
 * @DependOn  :在初始化 defaultWebSecurityManager 实例前 强制先初始化 adminRealm ,ehCacheManager。。。。。
 * @param realm
 * @param ehCacheManager
 * @param cookieRememberMeManager
 * @return
 */

@Bean(name = "securityManager")
@DependsOn({"adminRealm","ehCacheManager","cookieRememberMeManager"})
public DefaultWebSecurityManager getDefaultWebSecurityManager(AdminRealm realm, EhCacheManager ehCacheManager,CookieRememberMeManager cookieRememberMeManager) {
    DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
    //设置realm.
    defaultWebSecurityManager.setRealm(realm);
    defaultWebSecurityManager.setCacheManager(ehCacheManager);
    defaultWebSecurityManager.setRememberMeManager(cookieRememberMeManager);
    return defaultWebSecurityManager;
}
 
Example 5
Source File: ShiroConfig.java    From server-boilerplate with MIT License 5 votes vote down vote up
@Bean
public DefaultWebSecurityManager getDefaultWebSecurityManager() {
    DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
    dwsm.setRealm(getShiroRealm());
    dwsm.setCacheManager(getCacheManager());
    dwsm.setSessionManager(getSessionManager());
    return dwsm;
}
 
Example 6
Source File: ShiroConfiguration.java    From easyweb with Apache License 2.0 5 votes vote down vote up
@Bean(name = "securityManager")
    public DefaultWebSecurityManager getDefaultWebSecurityManager(
            SystemAuthorizingRealm myShiroRealm,
            DefaultWebSessionManager sessionManager,
            CacheManager shiroCacheManager) {
        DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
        dwsm.setRealm(myShiroRealm);
        dwsm.setSessionManager(sessionManager);
//      <!-- 用户授权/认证信息Cache, 采用redis 缓存 -->
        dwsm.setCacheManager(shiroCacheManager);
        return dwsm;
    }
 
Example 7
Source File: ShiroConfig.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@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;
}
 
Example 8
Source File: ShiroConfig.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@Bean
public SecurityManager securityManager(@Qualifier("authRealm")AuthRealm authRealm){
    logger.info("- - - - - - -shiro开始加载- - - - - - ");
    DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
    defaultWebSecurityManager.setRealm(authRealm);
    defaultWebSecurityManager.setRememberMeManager(rememberMeManager());
    defaultWebSecurityManager.setSessionManager(webSessionManager());
    defaultWebSecurityManager.setCacheManager(cacheManager());
    return defaultWebSecurityManager;
}
 
Example 9
Source File: ShiroConfiguration.java    From watchdog-framework with MIT License 5 votes vote down vote up
@Bean
public SecurityManager securityManager(RedisCacheManager RedisCacheManager){
    DefaultWebSecurityManager manager =  new DefaultWebSecurityManager();
    manager.setRealm(myRealm());
    manager.setCacheManager(RedisCacheManager);
    /*
    * 关闭session存储,禁用Session作为存储策略的实现,
    * 但它没有完全地禁用Session所以需要配合SubjectFactory中的context.setSessionCreationEnabled(false)
    */
    //manager.setSessionManager(sessionManager());
    ((DefaultSessionStorageEvaluator) ((DefaultSubjectDAO)manager.getSubjectDAO())
            .getSessionStorageEvaluator()).setSessionStorageEnabled(false);
    manager.setSubjectFactory(new AgileSubjectFactory());
    return manager;
}
 
Example 10
Source File: ShiroConfiguration.java    From spring-boot-seed with MIT License 5 votes vote down vote up
/**
 * SecurityManager: 安全管理器,注入有Realm、SessionManager、RememberMeManager
 *
 * @return SecurityManager
 */
@Bean
public SecurityManager securityManager() {
    DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
    defaultWebSecurityManager.setRealm(baseRealm());
    defaultWebSecurityManager.setSessionManager(sessionManager());
    defaultWebSecurityManager.setRememberMeManager(rememberMeManager());
    return defaultWebSecurityManager;
}
 
Example 11
Source File: ShiroBaseConfigure.java    From ueboot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 当用户的环境没有配置redisTemplate时则使用ehcache做缓存
 *
 * @param realm realm
 * @return DefaultWebSecurityManager
 */
@Bean
@Conditional(RedisDisabledCondition.class)
public DefaultWebSecurityManager webSecurityManager(Realm realm) {
    DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
    securityManager.setRealm(realm);
    //使用ehcache当缓存
    EhCacheManager cacheManager = new EhCacheManager();
    securityManager.setCacheManager(cacheManager);
    return securityManager;
}
 
Example 12
Source File: ShiroBaseConfigure.java    From ueboot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 当用户的环境配置了redisTemplate时则使用Redis做缓存
 *
 * @param realm         realm
 * @param redisTemplate spring RedisTemplate
 * @return DefaultWebSecurityManager
 */
@Bean
@Conditional(RedisEnableCondition.class)
public DefaultWebSecurityManager defaultWebSecurityManager(Realm realm, RedisTemplate<Object, Object> redisTemplate) {
    DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
    securityManager.setRealm(realm);
    //使用自定义的Redis缓存实现,依赖redisTemplate,keyNamespace可以默认为空
    securityManager.setCacheManager(this.getCacheManager(redisTemplate));
    return securityManager;
}
 
Example 13
Source File: ShiroConfig.java    From litemall with MIT License 5 votes vote down vote up
@Bean
public DefaultWebSecurityManager defaultWebSecurityManager() {
    DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
    securityManager.setRealm(realm());
    securityManager.setSessionManager(sessionManager());
    return securityManager;
}
 
Example 14
Source File: ShiroConfig.java    From blog-sample with Apache License 2.0 5 votes vote down vote up
/**
 * 注入securityManager
 */
@Bean
public SecurityManager securityManager() {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    manager.setRealm(shiroRealm());
    return manager;
}
 
Example 15
Source File: ShiroConfig.java    From fastdep with Apache License 2.0 5 votes vote down vote up
/**
 * securityManager
 *
 * @param authorizingRealm AuthorizingRealm bean
 * @return securityManager
 */
@Bean("securityManager")
@ConditionalOnMissingBean(SecurityManager.class)
public DefaultWebSecurityManager getManager(AuthorizingRealm authorizingRealm) {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    manager.setRealm(authorizingRealm);
    DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
    DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
    defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
    subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
    manager.setSubjectDAO(subjectDAO);
    return manager;
}
 
Example 16
Source File: ShiroConfiguration.java    From jee-universal-bms with Apache License 2.0 5 votes vote down vote up
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager() {
    DefaultWebSecurityManager webSecurityManager = new DefaultWebSecurityManager();
    webSecurityManager.setRealm(getShiroJdbcRealm());
    // webSecurityManager.setCacheManager(getEhCacheManager());
    webSecurityManager.setCacheManager(getCacheManager());
    webSecurityManager.setSessionManager(getSessionManager());
    return webSecurityManager;
}
 
Example 17
Source File: ShiroConfiguration.java    From chronus with Apache License 2.0 5 votes vote down vote up
@Bean
public DefaultWebSecurityManager securityManager(MyShiroRealm myShiroRealm, DefaultWebSessionManager sessionManager) {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    manager.setRealm(myShiroRealm);
    manager.setSessionManager(sessionManager);
    return manager;
}
 
Example 18
Source File: ShiroConfig.java    From learnjavabug with MIT License 4 votes vote down vote up
@Bean
SecurityManager securityManager() {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    manager.setRealm(myRealm());
    return manager;
}
 
Example 19
Source File: ShiroConfig.java    From learnjavabug with MIT License 4 votes vote down vote up
@Bean
SecurityManager securityManager() {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    manager.setRealm(myRealm());
    return manager;
}
 
Example 20
Source File: ShiroConfiguration.java    From springboot-shiro-cas-mybatis with MIT License 3 votes vote down vote up
/**
    * 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;
}