Example usage for org.apache.shiro.config Ini DEFAULT_SECTION_NAME

List of usage examples for org.apache.shiro.config Ini DEFAULT_SECTION_NAME

Introduction

In this page you can find the example usage for org.apache.shiro.config Ini DEFAULT_SECTION_NAME.

Prototype

String DEFAULT_SECTION_NAME

To view the source code for org.apache.shiro.config Ini DEFAULT_SECTION_NAME.

Click Source Link

Usage

From source file:com.centfor.frame.shiro.FrameShiroFilterFactoryBean.java

License:Apache License

/**
 * A convenience method that sets the {@link #setFilterChainDefinitionMap(java.util.Map) filterChainDefinitionMap}
 * property by accepting a {@link java.util.Properties Properties}-compatible string (multi-line key/value pairs).
 * Each key/value pair must conform to the format defined by the
 * {@link FilterChainManager#createChain(String,String)} JavaDoc - each property key is an ant URL
 * path expression and the value is the comma-delimited chain definition.
 *
 * @param definitions a {@link java.util.Properties Properties}-compatible string (multi-line key/value pairs)
 *                    where each key/value pair represents a single urlPathExpression-commaDelimitedChainDefinition.
 *///www .  j  av  a  2 s . c o  m
public void setFilterChainDefinitions(String definitions) {
    Ini ini = new Ini();
    ini.load(definitions);
    //did they explicitly state a 'urls' section?  Not necessary, but just in case:
    Ini.Section section = ini.getSection(IniFilterChainResolverFactory.URLS);
    if (CollectionUtils.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);
    }
    setFilterChainDefinitionMap(section);
}

From source file:com.codestudio.dorm.web.security.shiro.ChainDefinitionSectionMetaSource.java

License:Open Source License

@Override
public Section getObject() throws Exception {
    // ??//from  ww  w  . j a v  a2  s  . c o m
    Ini ini = new Ini();
    // url
    ini.load(filterChainDefinitions);
    Ini.Section section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
    return section;
}

From source file:com.ineunet.knife.security.DefaultChainDefinitionSectionInternal.java

License:Apache License

Section getObject() throws BeansException {
    Ini ini = new Ini();
    ini.load(defaultChainDefinitionSection.filterChainDefinitions);
    //did they explicitly state a 'urls' section?  Not necessary, but just in case:
    Ini.Section section = ini.getSection(IniFilterChainResolverFactory.URLS);
    if (CollectionUtils.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);
    }//from   w  w w. j a v  a 2  s .  co m
    defaultChainDefinitionSection.section = section;
    return section;
}

From source file:com.stormpath.shiro.servlet.config.IniPropertiesSource.java

License:Apache License

@Override
public Map<String, String> getProperties() {

    if (CollectionUtils.isEmpty(ini)) {
        return Collections.emptyMap();
    }/*  ww  w  .j a va2s .com*/

    // find the 'stormpath' config section, otherwise return an empty map
    Ini.Section section = ini.getSection(STORMPATH_CONFIG_SECTION_NAME);
    if (CollectionUtils.isEmpty(section)) {
        section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
    }

    if (CollectionUtils.isEmpty(section)) {
        return Collections.emptyMap();
    }

    // we now have a Ini section with some content
    TreeMap<String, String> allProperties = new TreeMap<String, String>(section);
    String keyPrefix = "stormpath.";
    return Collections.unmodifiableMap(allProperties.subMap(keyPrefix, keyPrefix + Character.MAX_VALUE));

}

From source file:com.stormpath.shiro.servlet.env.StormpathShiroIniEnvironment.java

License:Apache License

private Ini.Section getConfigSection(Ini ini) {

    Ini.Section configSection = ini.getSection(IniSecurityManagerFactory.MAIN_SECTION_NAME);
    if (CollectionUtils.isEmpty(configSection)) {
        configSection = ini.getSection(Ini.DEFAULT_SECTION_NAME);
        if (configSection == null) {
            configSection = ini.addSection(Ini.DEFAULT_SECTION_NAME);
        }//from  w  w  w . j  av  a 2s. c o  m
    }

    return configSection;
}

From source file:com.webarch.common.shiro.dynamic.DynamicPermissionServiceImpl.java

License:Apache License

/**
 * ?????????shiro??map/* w ww  .j  a  va  2s  .  com*/
 * {@see org.apache.shiro.spring.web.ShiroFilterFactoryBean#setFilterChainDefinitions(String)}
 *
 * @return Section
 */
private Map<String, String> generateSection() {
    Ini ini = new Ini();
    ini.load(definitions); // ?????
    Ini.Section section = ini.getSection(IniFilterChainResolverFactory.URLS); // 
    if (CollectionUtils.isEmpty(section)) {
        section = ini.getSection(Ini.DEFAULT_SECTION_NAME);//?,?
    }
    /**
     * ?????
     */
    Map<String, String> permissionMap = loadDynamicPermission();
    if (!CollectionUtils.isEmpty(permissionMap)) {
        if (CollectionUtils.isEmpty(section)) {
            logger.error(
                    "*********?????URL??????*********");
            return permissionMap;
        } else {
            section.putAll(permissionMap);
        }
    }
    return section;
}

From source file:net.cloudkit.enterprises.infrastructure.shiro.ChainDefinitionSectionMetaSource.java

License:Apache License

@Override
public Section getObject() throws Exception {

    // TODO ?? Resource

    Ini ini = new Ini();
    // url/*from ww  w.  j  a v  a  2s . co  m*/
    ini.load(filterChainDefinitions);
    logger.info("???:" + filterChainDefinitions);
    Section section = ini.getSection(Ini.DEFAULT_SECTION_NAME);

    // // Resourceurl,?sectionsectionfilterChainDefinitionMap,?URL,??
    // for (Iterator it = list.iterator(); it.hasNext();) {
    //     Resource resource = it.next();
    //     // ?section
    //     if (StringUtils.isNotEmpty(resource.getValue()) && StringUtils.isNotEmpty(resource.getPermission())) {
    //         section.put(resource.getValue(), MessageFormat.format(PERMISSION_STRING, resource.getPermission()));
    //     }
    //
    // }

    // Permissionurl,?sectionsectionfilterChainDefinitionMap,
    // ?URL,??
    logger.info("??????.");
    // TODO ??????
    /*
    for (Iterator<ResourceDTO> it = resourceList.iterator(); it.hasNext(); ) {
    ResourceDTO resource = it.next();
    // ?section
    if (StringUtils.isNotEmpty(resource.getPath()) && StringUtils.isNotEmpty(resource.getName())) {
        section.put(resource.getPath(), MessageFormat.format(PERMISSION_STRING, resource.getCode()));
        logger.info(resource.getPath() + ":" + MessageFormat.format(PERMISSION_STRING, resource.getCode()));
    }
    }
    */
    return section;
}

From source file:net.ili.base.services.authority.MyFilterChainDefinition.java

/**
 *
 * @return @throws Exception/*from www  .j  a va2 s. c  o  m*/
 */
@Override
public Ini.Section getObject() throws Exception {
    Ini defaultIni = new Ini();
    Ini ini = new Ini();

    //url
    if (StringUtils.isNotEmpty(filterChainDefinitions)) {
        defaultIni.load(filterChainDefinitions);
    }
    ini.addSection(Ini.DEFAULT_SECTION_NAME);
    Ini.Section section = ini.getSection(Ini.DEFAULT_SECTION_NAME);

    //?Resource
    List<Resource> list = dao.findAll();
    for (Resource resource : list) {
        //?section
        if (StringUtils.isNotEmpty(resource.getUrl()) && StringUtils.isNotEmpty(resource.getPermission())) {
            section.put(resource.getUrl(), MessageFormat.format(PREMISSIONEXP, resource.getPermission()));
        }
    }
    return section;
}

From source file:org.apache.mycat.advisor.common.security.shiro.dynamic.DynamicPermissionServiceImpl.java

License:Apache License

/**
 * ?????????shiro??map//w  w w  .j a  v  a 2s . co m
 * {@see org.apache.shiro.spring.web.ShiroFilterFactoryBean#setFilterChainDefinitions(String)}
 *
 * @return Section
 */
private Map<String, String> generateSection() {
    Ini ini = new Ini();
    ini.load(definitions); // ?????
    Ini.Section section = ini.getSection(IniFilterChainResolverFactory.DEFAULT_INI_RESOURCE_PATH); // 
    if (CollectionUtils.isEmpty(section)) {
        section = ini.getSection(Ini.DEFAULT_SECTION_NAME);//?,?
    }
    /**
     * ?????
     */
    Map<String, String> permissionMap = loadDynamicPermission();
    if (!CollectionUtils.isEmpty(permissionMap)) {
        if (CollectionUtils.isEmpty(section)) {
            logger.error(
                    "*********?????URL??????*********");
            return permissionMap;
        } else {
            section.putAll(permissionMap);
        }
    }
    return section;
}

From source file:org.bigmouth.nvwa.authority.ChainDefinitionSectionMetaSource.java

License:Apache License

@Override
public Section getObject() throws Exception {
    // ?Resource/*from w  w w  .  j  av a 2  s  .c om*/
    List<Resource> list = resourceDao.queryAll();
    Ini ini = new Ini();
    // url
    ini.load(filterChainDefinitions);
    Ini.Section section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
    // Resourceurl,?sectionsectionfilterChainDefinitionMap,
    // ?URL,??
    for (Iterator<Resource> it = list.iterator(); it.hasNext();) {
        Resource resource = it.next();
        // ?section
        if (StringUtils.isNotEmpty(resource.getUrl()) && StringUtils.isNotEmpty(resource.getIdentifying())) {
            section.put(resource.getUrl(), MessageFormat.format(PREMISSION_STRING, resource.getIdentifying()));
        }
    }
    return section;
}