19 package org.turro.security;
22 import java.io.FileReader;
23 import java.io.FileWriter;
24 import java.io.IOException;
25 import java.io.Reader;
26 import java.io.Writer;
27 import java.util.TreeMap;
28 import java.util.TreeSet;
29 import java.util.logging.Level;
30 import java.util.logging.Logger;
31 import org.turro.string.Strings;
32 import org.turro.configuration.JsonConfiguration;
41 private final TreeMap<String, TreeSet<String>> rolePermissions =
new TreeMap<>();
52 return rolePermissions;
57 private void prepareSaving() {
62 try(Reader reader =
new FileReader(file)) {
63 return JsonConfiguration.read(reader,
RoleMap.class);
64 }
catch (IOException ex) {
65 Logger.getLogger(
RoleMap.class.
getName()).log(Level.SEVERE,
null, ex);
71 try(Writer writer =
new FileWriter(file)) {
72 roleMap.prepareSaving();
73 JsonConfiguration.write(writer, roleMap);
74 }
catch (IOException ex) {
75 Logger.getLogger(
RoleMap.class.
getName()).log(Level.SEVERE,
null, ex);
static RoleMap loadFrom(File file)
void setName(String name)
static void saveTo(File file, RoleMap roleMap)
TreeMap< String, TreeSet< String > > getRolePermissions()