private void logIniContents(Ini ini) { // TODO use Logger? System.out.println("Shiro INI contents"); for (Map.Entry<String, Ini.Section> entry : ini.entrySet()) { System.out.println("Section : " + entry.getKey()); for (Map.Entry<String, String> sectionEntry : entry.getValue().entrySet()) { System.out.println(sectionEntry.getKey() + " = " + sectionEntry.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); } } } } }
public static Ini copyIniFile(Ini originalFile){ Set<Entry<String, Section>> entries = originalFile.entrySet(); Ini emptyFile; try { FileInputStream file = new FileInputStream(new File(EMPTY_DATA_FILE_NAME)); emptyFile = new Ini(file); file.close(); } catch (Exception e) { e.printStackTrace(); return null; } for(Entry<String, Section> entry : entries){ String key = (String) entry.getKey(); Section section = (Section) entry.getValue(); copySection(key, section, emptyFile); } return emptyFile; } public static Ini.Section copySection(String key, Ini.Section origin, Ini destinationFile){ Ini.Section newSection = destinationFile.get(key); if(newSection==null) throw new IllegalArgumentException(); for(Entry<String, String> entry : origin.entrySet()){ newSection.put(entry.getKey().toString(), entry.getValue().toString()); } return newSection; }