section = addSection(entry.getKey()); section.putAll(entry.getValue());
private void processAdditionalIniFiles(Ini ini) { String additionalShiroIniFileNames = config.getAdditionalShiroIniFileNames(); if (additionalShiroIniFileNames != null && additionalShiroIniFileNames.trim().length() > 0) { String[] iniFileNames = additionalShiroIniFileNames.split(","); for (String iniFileName : iniFileNames) { Ini additionalIni = createIni(iniFileName, false); if (additionalIni != null) { for (Map.Entry<String, Ini.Section> sectionEntry : additionalIni.entrySet()) { Ini.Section section = ini.get(sectionEntry.getKey()); Map<String, String> sectionValues = new HashMap<String, String>(); for (Map.Entry<String, String> sectionValue : sectionEntry.getValue().entrySet()) { sectionValues.put(sectionValue.getKey(), sectionValue.getValue()); } section.putAll(sectionValues); } } } } }
@Override public Realm createRealm(Injector injector) { Ini ini = new Ini(); if (users != null && !users.isEmpty()) { ini.addSection("users").putAll(users); } if (roles != null && !roles.isEmpty()) { ini.addSection("roles").putAll(roles); } IniRealm realm = new IniRealm(ini); realm.setIni(ini); if (name != null) { realm.setName(name); } return realm; } }
@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(); }
private Section(Section defaults) { this(defaults.getName()); putAll(defaults.props); }
Ini ini = new Ini(); ini.setComment(" Main comment "); //comment about the file //add a section comment, a section and a value ini.putComment("mySectionX", " Comment about the section"); ini.put("mySectionX", "myKey1", "value1"); //adding many parameters at one in a section String[] keyList = {value1, value2, value3}; ini.add("mySectionY"); Ini.Section names = ini.get("mySectionY"); names.putAll("myKey1", keyList); //put all new elements at once ... ini.store(new File(iniFileName));
private Section(Section defaults) { this(defaults.getName()); putAll(defaults.props); }