Search in sources :

Example 1 with MCRAccessInterface

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");
        }
    }
}
Also used : MCRAccessInterface(org.mycore.access.MCRAccessInterface)

Example 2 with MCRAccessInterface

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");
        }
    }
}
Also used : MCRAccessInterface(org.mycore.access.MCRAccessInterface)

Example 3 with MCRAccessInterface

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);
}
Also used : MCRAccessInterface(org.mycore.access.MCRAccessInterface) Element(org.jdom2.Element) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand)

Example 4 with MCRAccessInterface

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);
}
Also used : MCRAccessInterface(org.mycore.access.MCRAccessInterface) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand)

Example 5 with MCRAccessInterface

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("");
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) MCRAccessInterface(org.mycore.access.MCRAccessInterface) Element(org.jdom2.Element) XMLOutputter(org.jdom2.output.XMLOutputter) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand)

Aggregations

MCRAccessInterface (org.mycore.access.MCRAccessInterface)13 MCRCommand (org.mycore.frontend.cli.annotation.MCRCommand)7 Element (org.jdom2.Element)5 Document (org.jdom2.Document)2 XMLOutputter (org.jdom2.output.XMLOutputter)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 MCRException (org.mycore.common.MCRException)1 MCRFileContent (org.mycore.common.content.MCRFileContent)1 MCRDerivate (org.mycore.datamodel.metadata.MCRDerivate)1 MCRMetaIFS (org.mycore.datamodel.metadata.MCRMetaIFS)1 MCRMetaLinkID (org.mycore.datamodel.metadata.MCRMetaLinkID)1 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)1 MCRPath (org.mycore.datamodel.niofs.MCRPath)1