use of net.sourceforge.processdash.security.TamperDeterrent.TamperException in project processdash by dtuma.
the class PermissionsManager method readRoles.
/**
* Read the roles that are defined in this dataset.
*/
private void readRoles() throws IOException, TamperException {
Map roles = new TreeMap();
if (Settings.isTeamMode() && rolesFile.isFile()) {
verifyFile(rolesFile);
try {
// open, parse, and load the roles XML file
InputStream in = new BufferedInputStream(new FileInputStream(rolesFile));
Element xml = XMLUtils.parse(in).getDocumentElement();
readRolesFromXml(roles, xml);
// store the timestamp for role data
rolesTimestamp = XMLUtils.getXMLDate(xml, TIMESTAMP_ATTR);
if (rolesTimestamp == null)
rolesTimestamp = new Date(rolesFile.lastModified());
} catch (Exception e) {
throw new IOException(rolesFile.getName(), e);
}
} else {
// no file present? read default roles from extension points
long ts = 1;
for (Element xml : ExtensionManager.getXmlConfigurationElements(STANDARD_ROLES_TAG)) {
readRolesFromXml(roles, xml);
ts = Math.max(ts, ExtensionManager.getModTimeOfSource(xml));
// overrides to the standard roles.)
if (Settings.isPersonalMode())
break;
}
rolesTimestamp = new Date(ts);
}
this.roles = Collections.synchronizedMap(roles);
this.rolesDirty = false;
}
use of net.sourceforge.processdash.security.TamperDeterrent.TamperException in project processdash by dtuma.
the class PermissionsManager method readUsers.
/**
* Read the users that are defined in this dataset.
*/
private void readUsers() throws IOException, TamperException {
Map users = new TreeMap();
if (Settings.isTeamMode() && usersFile.isFile()) {
verifyFile(usersFile);
try {
// open and parse the users XML file
InputStream in = new BufferedInputStream(new FileInputStream(usersFile));
Element xml = XMLUtils.parse(in).getDocumentElement();
// find and parse the <user> tags in the document
NodeList nl = xml.getElementsByTagName(USER_TAG);
for (int i = 0; i < nl.getLength(); i++) {
User u = readUser((Element) nl.item(i));
users.put(u.getUsernameLC(), u);
}
// store the timestamp for user data
usersTimestamp = XMLUtils.getXMLDate(xml, TIMESTAMP_ATTR);
if (usersTimestamp == null)
usersTimestamp = new Date(usersFile.lastModified());
} catch (Exception e) {
throw new IOException(usersFile.getName(), e);
}
} else {
// no file present? create a catch-all user definition
String catchAllName = resources.getString("All_Other_Users");
User u = new User(catchAllName, CATCH_ALL_USER_ID, false, Collections.singletonList(STANDARD_ROLE_ID));
users.put(u.getUsernameLC(), u);
usersTimestamp = new Date(1);
}
this.users = Collections.synchronizedMap(users);
this.usersDirty = false;
}
Aggregations