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


Java Ini.loadFromPath方法代码示例

本文整理汇总了Java中org.apache.shiro.config.Ini.loadFromPath方法的典型用法代码示例。如果您正苦于以下问题:Java Ini.loadFromPath方法的具体用法?Java Ini.loadFromPath怎么用?Java Ini.loadFromPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.shiro.config.Ini的用法示例。


在下文中一共展示了Ini.loadFromPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shiroFilter

import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
@Bean
public ShiroFilterFactoryBean shiroFilter() {
	ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean();
	
	//设置Filter映射
	LinkedHashMap<String, Filter> filterMap = new LinkedHashMap<>();
	DefaultCasFilter casFilter = new DefaultCasFilter();
	casFilter.setFailureUrl(loginProperties.getFailureUrl()); //配置验证错误时的失败页面
	casFilter.setReloginUrl(loginProperties.getCasLogin() + "&msg={0}"); //验证错误后显示登录页面,并提示错误信息。只试用于ErrorContext异常
	casFilter.setLogoutUrl(loginProperties.getCasLogout());
	filterMap.put("casFilter", casFilter);
	LogoutFilter logoutFilter = new LogoutFilter();
	logoutFilter.setRedirectUrl(loginProperties.getCasLogout() + "?service=" + loginProperties.getCasLogoutCallback());
	filterMap.put("logoutFilter", logoutFilter);
	filterMap.put("perms", new DefaultPermissionsAuthorizationFilter());
	filterMap.put("authc", new DefaultFormAuthenticationFilter());
	filterMap.put("sense", new SenseLoginFilter());
	factoryBean.setFilters(filterMap);
	
	factoryBean.setSecurityManager(securityManager());
	factoryBean.setLoginUrl(loginProperties.getCasLogin());
	factoryBean.setUnauthorizedUrl(loginProperties.getUnauthorizedUrl());
	//加载权限配置
	Ini ini = new Ini();
	ini.loadFromPath(loginProperties.getShiroFilterFile());
	//did they explicitly state a 'urls' section?  Not necessary, but just in case:
	Ini.Section section = ini.getSection(IniFilterChainResolverFactory.URLS);
	if (MapUtils.isEmpty(section)) {
		//no urls section.  Since this _is_ a urls chain definition property, just assume the
		//default section contains only the definitions:
		section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
	}
	factoryBean.setFilterChainDefinitionMap(section);
	return factoryBean;
}
 
开发者ID:easycodebox,项目名称:easycode,代码行数:36,代码来源:ShiroConfig.java

示例2: convertPathToIni

import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
/**
 * Converts the specified file path to an {@link Ini} instance.
 * <p/>
 * If the path does not have a resource prefix as defined by {@link ResourceUtils#hasResourcePrefix(String)}, the
 * path is expected to be resolvable by the {@code ServletContext} via
 * {@link javax.servlet.ServletContext#getResourceAsStream(String)}.
 *
 * @param path the path of the INI resource to load into an INI instance.
 * @return an INI instance populated based on the given INI resource path.
 */
protected Ini convertPathToIni(String path) {

    Ini ini = new Ini();

    //SHIRO-178: Check for servlet context resource and not
    //only resource paths:
    if (!ResourceUtils.hasResourcePrefix(path)) {
        ini = getServletContextIniResource(path);
        if (ini == null) {
            String msg = "There is no servlet context resource corresponding to configPath '" + path + "'  If " +
                    "the resource is located elsewhere (not immediately resolveable in the servlet context), " +
                    "specify an appropriate classpath:, url:, or file: resource prefix accordingly.";
            throw new ConfigurationException(msg);
        }
    } else {
        //normal resource path - load as usual:
        ini.loadFromPath(path);
    }

    return ini;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:32,代码来源:IniShiroFilter.java

示例3: createSecurityManager

import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
public SecurityManager createSecurityManager(String securityFilePath) throws UnRetriableException{


        Ini ini = new Ini();
        ini.loadFromPath(securityFilePath);

        IOTIniSecurityManagerFactory iniSecurityManagerFactory = new IOTIniSecurityManagerFactory(ini, getIotSecurityDatastore(), getDefaultPartitionName());

        SecurityManager securityManager = iniSecurityManagerFactory.getInstance();

        if(securityManager instanceof IOTSecurityManager) {

            //configure the security manager.
            IOTSecurityManager iotSecurityManager = (IOTSecurityManager) securityManager;
            DefaultSessionManager sessionManager = (DefaultSessionManager) iotSecurityManager.getSessionManager();


            SecurityUtils.setSecurityManager(iotSecurityManager);

            //Assign session dao from the security datastore.
            sessionManager.setSessionDAO(getIotSecurityDatastore());

            sessionManager.setSessionListeners(getSessionListenerList());
            sessionManager.setSessionValidationSchedulerEnabled(true);
            sessionManager.setSessionValidationInterval(1000);

            return securityManager;


        }else {
            throw new UnRetriableException("Security manager has to be an instance of the default security manager (DefaultSecurityManager). "+securityManager.getClass().getName()+" was used instead." );
        }
    }
 
开发者ID:caricah,项目名称:iotracah,代码行数:34,代码来源:DefaultSecurityHandler.java


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