/** * Loads the specified raw INI-formatted text into this instance. * * @param iniConfig the raw INI-formatted text to load into this instance. * @throws ConfigurationException if the text cannot be loaded */ public void load(String iniConfig) throws ConfigurationException { load(new Scanner(iniConfig)); }
/** * Loads the INI-formatted text backed by the given Reader into this instance. This implementation will close the * reader after it has finished loading. * * @param reader the {@code Reader} from which to read the INI-formatted text */ public void load(Reader reader) { Scanner scanner = new Scanner(reader); try { load(scanner); } finally { try { scanner.close(); } catch (Exception e) { log.debug("Unable to cleanly close the InputStream scanner. Non-critical - ignoring.", e); } } }
protected Ini convertConfigToIni(String config) { Ini ini = new Ini(); ini.load(config); return ini; }
/** * Loads the INI-formatted text backed by the given InputStream into this instance. This implementation will * close the input stream after it has finished loading. It is expected that the stream's contents are * UTF-8 encoded. * * @param is the {@code InputStream} from which to read the INI-formatted text * @throws ConfigurationException if unable */ public void load(InputStream is) throws ConfigurationException { if (is == null) { throw new NullPointerException("InputStream argument cannot be null."); } InputStreamReader isr; try { isr = new InputStreamReader(is, DEFAULT_CHARSET_NAME); } catch (UnsupportedEncodingException e) { throw new ConfigurationException(e); } load(isr); }
/** * Loads data from the specified resource path into this current {@code Ini} instance. 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 into this instance. * @throws ConfigurationException if the path cannot be loaded */ public void loadFromPath(String resourcePath) throws ConfigurationException { InputStream is; try { is = ResourceUtils.getInputStreamForPath(resourcePath); } catch (IOException e) { throw new ConfigurationException(e); } load(is); }
/** * Returns the INI instance reflecting the specified servlet context resource path or {@code null} if no * resource was found. * * @param servletContextPath the servlet context resource path of the INI file to load * @return the INI instance reflecting the specified servlet context resource path or {@code null} if no * resource was found. * @since 1.2 */ protected Ini getServletContextIniResource(String servletContextPath) { String path = WebUtils.normalize(servletContextPath); if (getServletContext() != null) { InputStream is = getServletContext().getResourceAsStream(path); if (is != null) { Ini ini = new Ini(); ini.load(is); if (CollectionUtils.isEmpty(ini)) { log.warn("ServletContext INI resource '" + servletContextPath + "' exists, but it did not contain " + "any data."); } return ini; } } return null; }
@Inject public KillBillOktaRealm(final SecurityConfig securityConfig) { this.securityConfig = securityConfig; this.httpClient = new AsyncHttpClient(new AsyncHttpClientConfig.Builder().setRequestTimeout(DEFAULT_TIMEOUT_SECS * 1000).build()); if (securityConfig.getShiroOktaPermissionsByGroup() != null) { final Ini ini = new Ini(); // When passing properties on the command line, \n can be escaped ini.load(securityConfig.getShiroOktaPermissionsByGroup().replace("\\n", "\n")); for (final Section section : ini.getSections()) { for (final String role : section.keySet()) { final Collection<String> permissions = ImmutableList.<String>copyOf(SPLITTER.split(section.get(role))); permissionsByGroup.put(role, permissions); } } } }
/** * 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. */ 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); }
ini.load(is); } else { if (required) {
final Ini ini = new Ini(); ini.load(securityConfig.getShiroLDAPPermissionsByGroup().replace("\\n", "\n")); for (final Section section : ini.getSections()) { for (final String rawRole : section.keySet()) {
@Override public Ini.Section getObject() throws Exception { Ini ini = new Ini(); ini.load(filterChainDefinitions); Ini.Section section = ini.getSection("urls"); if (CollectionUtils.isEmpty(section)) { section = ini.getSection(""); } return section; }
/** * Loads the specified raw INI-formatted text into this instance. * * @param iniConfig the raw INI-formatted text to load into this instance. * @throws ConfigurationException if the text cannot be loaded */ public void load(String iniConfig) throws ConfigurationException { load(new Scanner(iniConfig)); }
/** * Loads the INI-formatted text backed by the given Reader into this instance. This implementation will close the * reader after it has finished loading. * * @param reader the {@code Reader} from which to read the INI-formatted text */ public void load(Reader reader) { Scanner scanner = new Scanner(reader); try { load(scanner); } finally { try { scanner.close(); } catch (Exception e) { log.debug("Unable to cleanly close the InputStream scanner. Non-critical - ignoring.", e); } } }
InputStream is = new BufferedInputStream(new FileInputStream(fileList[i])); Reader reader = new InputStreamReader(is, "UTF-16"); Ini ini = new Ini(); ini.load(reader); System.out.println(ini.keySet());
public static Ini loadFromPath(FileSystem fileSystem, Path path) throws IOException { InputStream inputStream = null; try { LOGGER.debug("Opening " + path); inputStream = fileSystem.open(path); Ini ini = new Ini(); ini.load(inputStream); return ini; } finally { if(inputStream != null) { try { inputStream.close(); } catch (IOException e) { LOGGER.warn("Error closing " + inputStream); } } } }
public IniEnvironment(String iniConfig) { Ini ini = new Ini(); ini.load(iniConfig); this.ini = ini; init(); }
@PostConstruct public void postConstruct() throws ConfigurationException, IOException { URL iniURL = getShiroIniURL(); if (iniURL != null) { Ini ini = new Ini(); ini.load(iniURL.openStream()); IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini); manager = factory.getInstance(); } }
/** * Loads data from the specified resource path into this current {@code Ini} instance. 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 into this instance. * @throws ConfigurationException if the path cannot be loaded */ public void loadFromPath(String resourcePath) throws ConfigurationException { InputStream is; try { is = ResourceUtils.getInputStreamForPath(resourcePath); } catch (IOException e) { throw new ConfigurationException(e); } load(is); }
@Inject public KillBillOktaRealm(final SecurityConfig securityConfig) { this.securityConfig = securityConfig; this.httpClient = new AsyncHttpClient(new AsyncHttpClientConfig.Builder().setRequestTimeout(DEFAULT_TIMEOUT_SECS * 1000).build()); if (securityConfig.getShiroOktaPermissionsByGroup() != null) { final Ini ini = new Ini(); // When passing properties on the command line, \n can be escaped ini.load(securityConfig.getShiroOktaPermissionsByGroup().replace("\\n", "\n")); for (final Section section : ini.getSections()) { for (final String role : section.keySet()) { final Collection<String> permissions = ImmutableList.<String>copyOf(SPLITTER.split(section.get(role))); permissionsByGroup.put(role, permissions); } } } }
public FilterChainResolver createFilterChainResolver() { if (ioc.has("shiroFilterChainResolver")) { return ioc.get(FilterChainResolver.class, "shiroFilterChainResolver"); } else { log.debug("ioc name=shiroFilterChainResolver not found, fallback to " + ShiroEnvStarter.PROP_INIT_URLS); String iniUrls = "[urls]\r\n" + conf.get(ShiroEnvStarter.PROP_INIT_URLS, "").trim(); log.debug("shiro ini urls ---> \r\n" + iniUrls); Ini ini = new Ini(); ini.load(iniUrls); IniFilterChainResolverFactory resolverFactory = new IniFilterChainResolverFactory(ini, objects); return resolverFactory.getInstance(); } }