Example usage for org.apache.shiro.web.config IniFilterChainResolverFactory URLS

List of usage examples for org.apache.shiro.web.config IniFilterChainResolverFactory URLS

Introduction

In this page you can find the example usage for org.apache.shiro.web.config IniFilterChainResolverFactory URLS.

Prototype

String URLS

To view the source code for org.apache.shiro.web.config IniFilterChainResolverFactory URLS.

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.
 *///from www .  j a v  a2s . co 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.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);
    }/* w w  w. j  a  va2s  . co m*/
    defaultChainDefinitionSection.section = section;
    return section;
}

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

License:Apache License

private void addDefaultsToIni(Ini ini) {

    // TODO: this is not ideal, we need to make shiro a bit more flexible
    // and this is tightly coupled with the following method
    Ini.Section configSection = getConfigSection(ini);

    // lazy associate the client with the realm, so changes can be made if needed.
    if (!configSection.containsKey(DEFAULTS_STORMPATH_REALM_PROPERTY + ".client")) {
        configSection.put(DEFAULTS_STORMPATH_REALM_PROPERTY + ".client",
                "$" + DEFAULTS_STORMPATH_CLIENT_PROPERTY);
    }// ww w  . j  a  va  2s . c  om

    // global properties 'shiro.*' are not loaded from the defaults, we must set it in the ini.
    if (!configSection.containsKey("shiro.loginUrl")) {
        configSection.put("shiro.loginUrl", "/login");
    }

    // protect the world if the URL section is missing
    Ini.Section urls = ini.getSection(IniFilterChainResolverFactory.URLS);
    Ini.Section filters = ini.getSection(IniFilterChainResolverFactory.FILTERS); // deprecated behavior
    if (CollectionUtils.isEmpty(urls) && CollectionUtils.isEmpty(filters)) {
        ini.setSectionProperty(IniFilterChainResolverFactory.URLS, "/**", DefaultFilter.authc.name());
    }

}

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

License:Apache License

/**
 * ?????????shiro??map//from   w  w  w  .  j a v  a2s  . 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.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:zcu.xutil.misc.ShiroFilterFactory.java

License:Apache License

public AbstractShiroFilter getShiroFilter() {
    DefaultFilterChainManager manager = new DefaultFilterChainManager();
    for (Filter filter : manager.getFilters().values())
        applyGlobalPropertiesIfNecessary(filter);
    for (Map.Entry<String, Filter> entry : filters.entrySet()) {
        applyGlobalPropertiesIfNecessary(entry.getValue());
        manager.addFilter(entry.getKey(), entry.getValue());
    }/*from   w w  w.  ja v a 2s .  c o  m*/
    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);
    for (Map.Entry<String, String> entry : section.entrySet())
        manager.createChain(entry.getKey(), entry.getValue());
    PathMatchingFilterChainResolver chainResolver = new PathMatchingFilterChainResolver();
    chainResolver.setFilterChainManager(manager);
    return new XSFilter((WebSecurityManager) securityManager, chainResolver);
}