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

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

Introduction

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

Prototype

public void setSectionProperty(String sectionName, String propertyName, String propertyValue) 

Source Link

Document

Sets a name/value pair for the section with the given sectionName .

Usage

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);
    }/*  w  w  w .j a v  a2  s  . co  m*/

    // 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());
    }

}