当前位置: 首页>>代码示例>>Java>>正文


Java DefaultWebSecurityManager类代码示例

本文整理汇总了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;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:32,代码来源:ShiroCasConfiguration.java

示例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;
}
 
开发者ID:fireshort,项目名称:spring-boot-quickstart,代码行数:20,代码来源:ShiroConfiguration.java

示例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;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:ShiroConfiguration.java

示例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;
}
 
开发者ID:Eagle-OJ,项目名称:eagle-oj-api,代码行数:14,代码来源:ShiroConfig.java

示例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;
    }
 
开发者ID:egojit8,项目名称:easyweb,代码行数:20,代码来源:ShiroConfiguration.java

示例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;
	}
 
开发者ID:wanghongfei,项目名称:shiro-spring-boot-starter,代码行数:19,代码来源:ShiroManager.java

示例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;
}
 
开发者ID:seagrape,项目名称:kekoa,代码行数:28,代码来源:ShiroConfiguration.java

示例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;
}
 
开发者ID:seagrape,项目名称:kekoa,代码行数:31,代码来源:KekoaShiroConfiguration.java

示例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;
}
 
开发者ID:easycodebox,项目名称:easycode,代码行数:24,代码来源:ShiroConfig.java

示例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;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:29,代码来源:ShiroSecurityComponentFactory.java

示例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;
    }
 
开发者ID:MTDdk,项目名称:jawn,代码行数:19,代码来源:JawnSecurityManagerFactory.java

示例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;
}
 
开发者ID:silb,项目名称:dropwizard-shiro,代码行数:23,代码来源:ShiroBundle.java

示例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;
    }
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:11,代码来源:ShiroCasConfiguration.java

示例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;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:ShiroConfig.java

示例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;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:ShiroConfig.java


注:本文中的org.apache.shiro.web.mgt.DefaultWebSecurityManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。