private Ini convertPathToIni(String path, boolean required) {

        //TODO - this logic is ugly - it'd be ideal if we had a Resource API to polymorphically encapsulate this behavior

        Ini ini = null;

        if (StringUtils.hasText(path)) {
            InputStream is = null;

            //SHIRO-178: Check for servlet context resource and not only resource paths:
            if (!ResourceUtils.hasResourcePrefix(path)) {
                is = getServletContextResourceStream(path);
            } else {
                try {
                    is = ResourceUtils.getInputStreamForPath(path);
                } catch (IOException e) {
                    if (required) {
                        throw new ConfigurationException(e);
                    } else {
                        if (LOGGER.isDebugEnabled()) {
                            LOGGER.debug("Unable to load optional path '" + path + "'.", e);
                        }
                    }
                }
            }
            if (is != null) {
                ini = new Ini();
                ini.load(is);
            } else {
                if (required) {
                    throw new ConfigurationException("Unable to load resource path '" + path + "'");
                }
            }
        }

        return ini;
    }
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.
@param required if the specified path must exist
@return an INI instance populated based on the given INI resource path.
web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java