/** * Creates a new {@code Ini} instance loaded with the INI-formatted data in the resource at the given path. The * resource path may be any value interpretable by the * {@link ResourceUtils#getInputStreamForPath(String) ResourceUtils.getInputStreamForPath} method. * * @param resourcePath the resource location of the INI data to load when creating the {@code Ini} instance. * @return a new {@code Ini} instance loaded with the INI-formatted data in the resource at the given path. * @throws ConfigurationException if the path cannot be loaded into an {@code Ini} instance. */ public static Ini fromResourcePath(String resourcePath) throws ConfigurationException { if (!StringUtils.hasLength(resourcePath)) { throw new IllegalArgumentException("Resource Path argument cannot be null or empty."); } Ini ini = new Ini(); ini.loadFromPath(resourcePath); return ini; }
/** * Returns a new Ini instance created from the default {@code classpath:shiro.ini} file, or {@code null} if * the file does not exist. * * @return a new Ini instance created from the default {@code classpath:shiro.ini} file, or {@code null} if * the file does not exist. */ public static Ini loadDefaultClassPathIni() { Ini ini = null; if (ResourceUtils.resourceExists(DEFAULT_INI_RESOURCE_PATH)) { log.debug("Found shiro.ini at the root of the classpath."); ini = new Ini(); ini.loadFromPath(DEFAULT_INI_RESOURCE_PATH); if (CollectionUtils.isEmpty(ini)) { log.warn("shiro.ini found at the root of the classpath, but it did not contain any data."); } } return ini; }
ini.loadFromPath(path);
/** * Returns a new Ini instance created from the default {@code classpath:shiro.ini} file, or {@code null} if * the file does not exist. * * @return a new Ini instance created from the default {@code classpath:shiro.ini} file, or {@code null} if * the file does not exist. */ public static Ini loadDefaultClassPathIni() { Ini ini = null; if (ResourceUtils.resourceExists(DEFAULT_INI_RESOURCE_PATH)) { log.debug("Found shiro.ini at the root of the classpath."); ini = new Ini(); ini.loadFromPath(DEFAULT_INI_RESOURCE_PATH); if (CollectionUtils.isEmpty(ini)) { log.warn("shiro.ini found at the root of the classpath, but it did not contain any data."); } } return ini; }
/** * * @param path * the file path, which is either absolute or relative to * <code>$KARAF_HOME</code> * @return Ini loaded from <code>path</code> */ static Ini createShiroIni(final String path) throws FileNotFoundException { File f = new File(path); Ini ini = new Ini(); final String fileBasedIniPath = createFileBasedIniPath(f.getAbsolutePath()); ini.loadFromPath(fileBasedIniPath); return ini; }
protected boolean authenticateUser(String config, UsernamePasswordToken token) throws ConfigurationException { Ini ini = new Ini(); try { ini.loadFromPath(config); return authenticateUser(ini, token); } catch (ConfigurationException e) { throw e; } }
protected boolean authenticateUser(String config, UsernamePasswordToken token) throws ConfigurationException { Ini ini = new Ini(); ini.loadFromPath(config); return authenticateUser(ini, token); }
/** * Creates a new {@code Ini} instance loaded with the INI-formatted data in the resource at the given path. The * resource path may be any value interpretable by the * {@link ResourceUtils#getInputStreamForPath(String) ResourceUtils.getInputStreamForPath} method. * * @param resourcePath the resource location of the INI data to load when creating the {@code Ini} instance. * @return a new {@code Ini} instance loaded with the INI-formatted data in the resource at the given path. * @throws ConfigurationException if the path cannot be loaded into an {@code Ini} instance. */ public static Ini fromResourcePath(String resourcePath) throws ConfigurationException { if (!StringUtils.hasLength(resourcePath)) { throw new IllegalArgumentException("Resource Path argument cannot be null or empty."); } Ini ini = new Ini(); ini.loadFromPath(resourcePath); return ini; }
/** * Returns a new Ini instance created from the default {@code classpath:shiro.ini} file, or {@code null} if * the file does not exist. * * @return a new Ini instance created from the default {@code classpath:shiro.ini} file, or {@code null} if * the file does not exist. */ public static Ini loadDefaultClassPathIni() { Ini ini = null; if (ResourceUtils.resourceExists(DEFAULT_INI_RESOURCE_PATH)) { log.debug("Found shiro.ini at the root of the classpath."); ini = new Ini(); ini.loadFromPath(DEFAULT_INI_RESOURCE_PATH); if (CollectionUtils.isEmpty(ini)) { log.warn("shiro.ini found at the root of the classpath, but it did not contain any data."); } } return ini; }
protected Subject getSubject(String config) throws ConfigurationException { Ini ini = new Ini(); ini.loadFromPath(config); try { return getSubject(ini); } catch (BadSubjectException e) { throw new ConfigurationException("Could not get Subject with Ini at " + config); } }
protected Subject getSubject(String config) throws ConfigurationException { Ini ini = new Ini(); ini.loadFromPath(config); try { return getSubject(ini); } catch (BadSubjectException e) { throw new ConfigurationException("Could not get Subject with Ini at " + config); } }
ini.loadFromPath(this.iniResourePath); apply(ini); if (ResourceUtils.resourceExists("classpath:shiro.ini")) { ini = new Ini(); ini.loadFromPath("classpath:shiro.ini"); apply(ini);
@Override public void init() throws ShiroException { Ini ini = new Ini(); Preconditions.checkNotNull(getConfigLocations()); for(String p : getConfigLocations()) { Ini subIni = new Ini(ini); subIni.loadFromPath(p); // add all values from the sub file to the main configuration for(Section section : subIni.getSections()) { Section existing = ini.getSection(section.getName()); if(existing == null) { existing = ini.addSection(section.getName()); } existing.putAll(section); } } setIni(ini); configure(); }