use of org.mycore.access.MCRAccessInterface in project mycore by MyCoRe-Org.
the class MCRMODSCommands method setDefaultPermissions.
protected static void setDefaultPermissions(MCRObjectID derivateID) {
if (CONFIG.getBoolean("MCR.Access.AddDerivateDefaultRule", true)) {
MCRAccessInterface ai = MCRAccessManager.getAccessImpl();
Collection<String> configuredPermissions = ai.getAccessPermissionsFromConfiguration();
for (String permission : configuredPermissions) {
MCRAccessManager.addRule(derivateID, permission, MCRAccessManager.getTrueRule(), "default derivate rule");
}
}
}
use of org.mycore.access.MCRAccessInterface in project mycore by MyCoRe-Org.
the class MCRUploadHandlerIFS method setDefaultPermissions.
protected void setDefaultPermissions(MCRObjectID derivateID) {
if (CONFIG.getBoolean("MCR.Access.AddDerivateDefaultRule", true)) {
MCRAccessInterface AI = MCRAccessManager.getAccessImpl();
Collection<String> configuredPermissions = AI.getAccessPermissionsFromConfiguration();
for (String permission : configuredPermissions) {
MCRAccessManager.addRule(derivateID, permission, MCRAccessManager.getTrueRule(), "default derivate rule");
}
}
}
use of org.mycore.access.MCRAccessInterface in project mycore by MyCoRe-Org.
the class MCRAccessCommands method permissionUpdateForID.
/**
* updates the permission for a given id and a given permission type with a
* given rule
*
* @param permission
* String type of permission like read, writedb, etc.
* @param id
* String the id of the object the rule is assigned to
* @param strFileRule
* String the path to the xml file, that contains the rule
* @param description
* String give a special description, if the semantics of your
* rule is multiple used
*/
@MCRCommand(syntax = "update permission {0} for id {1} with rulefile {2} described by {3}", help = "The command updates access rule for a given id of a given permission with a given special rule", order = 60)
public static void permissionUpdateForID(String permission, String id, String strFileRule, String description) throws Exception {
MCRAccessInterface AI = MCRAccessManager.getAccessImpl();
Element rule = getRuleFromFile(strFileRule);
if (rule == null) {
return;
}
AI.addRule(id, permission, rule, description);
}
use of org.mycore.access.MCRAccessInterface in project mycore by MyCoRe-Org.
the class MCRAccessCommands method deletePermission.
/**
* delete the permission {0}
*
* @param permission
* the name of the permission
*/
@MCRCommand(syntax = "delete permission {0}", help = "Remove a named permission entriy from the Access Control System.", order = 30)
public static void deletePermission(String permission) throws Exception {
MCRAccessInterface AI = MCRAccessManager.getAccessImpl();
AI.removeRule(permission);
}
use of org.mycore.access.MCRAccessInterface in project mycore by MyCoRe-Org.
the class MCRAccessCommands method listAllPermissions.
/**
* This method invokes MCRUserMgr.getAllPrivileges() and retrieves a
* ArrayList of all privileges stored in the persistent datastore.
*/
@MCRCommand(syntax = "list all permissions", help = "List all permission entries.", order = 20)
public static void listAllPermissions() throws MCRException {
MCRAccessInterface AI = MCRAccessManager.getAccessImpl();
Collection<String> permissions = AI.getPermissions();
boolean noPermissionsDefined = true;
for (String permission : permissions) {
noPermissionsDefined = false;
String description = AI.getRuleDescription(permission);
if (description.equals("")) {
description = "No description";
}
org.jdom2.Element rule = AI.getRule(permission);
LOGGER.info(" {}", permission);
LOGGER.info(" {}", description);
if (rule != null) {
org.jdom2.output.XMLOutputter o = new org.jdom2.output.XMLOutputter();
LOGGER.info(" {}", o.outputString(rule));
}
}
if (noPermissionsDefined) {
LOGGER.warn("No permissions defined");
}
LOGGER.info("");
}
Aggregations