Example usage for org.apache.shiro.web.filter.mgt DefaultFilter authcBasic

List of usage examples for org.apache.shiro.web.filter.mgt DefaultFilter authcBasic

Introduction

In this page you can find the example usage for org.apache.shiro.web.filter.mgt DefaultFilter authcBasic.

Prototype

DefaultFilter authcBasic

To view the source code for org.apache.shiro.web.filter.mgt DefaultFilter authcBasic.

Click Source Link

Usage

From source file:com.meltmedia.cadmium.servlets.shiro.WebEnvironment.java

License:Apache License

@Override
protected FilterChainResolver createFilterChainResolver() {
    Ini.Section section = this.getIni().getSection(TRUSTED_SECTION_NAME);
    trustedHosts = new ArrayList<String>();
    if (!CollectionUtils.isEmpty(section)) {
        logger.debug("Found " + TRUSTED_SECTION_NAME + " ini section in shiro.ini");
        for (String key : section.keySet()) {
            logger.debug("Adding " + section.get(key) + " to list of trusted ip addresses.");
            trustedHosts.add(section.get(key).trim());
        }//from w w w .  j av  a2  s  .  co  m
    }
    if (!CollectionUtils.isEmpty(trustedHosts)) {
        Ini.Section filterConfigs = getIni().getSection(IniFilterChainResolverFactory.FILTERS);
        if (CollectionUtils.isEmpty(filterConfigs)) {
            filterConfigs = getIni().addSection(IniFilterChainResolverFactory.FILTERS);
        }
        if (!filterConfigs.containsKey(DefaultFilter.authcBasic.name())) {
            filterConfigs.put(DefaultFilter.authcBasic.name(),
                    "com.meltmedia.cadmium.servlets.shiro.TrustedBasicHttpAuthenticationFilter");
            String trustedHostStr = "";
            for (String host : trustedHosts) {
                if (trustedHostStr.length() > 0) {
                    trustedHostStr += ",";
                }
                trustedHostStr += host;
            }
            filterConfigs.put(DefaultFilter.authcBasic.name() + ".trustedHosts", trustedHostStr);
        }
    }
    return super.createFilterChainResolver();
}