Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
import org.jdom2.output.XMLOutputter;
import org.mycore.access.MCRAccessManager;
import org.mycore.access.MCRRuleAccessInterface;
import org.mycore.access.mcrimpl.MCRAccessStore;
import org.mycore.access.mcrimpl.MCRRuleMapping;
import org.mycore.access.mcrimpl.MCRRuleStore;
import org.mycore.common.MCRException;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.common.xsl.uriresolver.MCRURIResolver;
Expand Down Expand Up @@ -155,6 +158,42 @@ public static void deleteAllPermissions() {
}
}

/**
* delete all ACL rule mappings and rules
*/
@MCRCommand(syntax = "delete all acl rules and mappings",
help = "Remove all rule mappings and rules from the Access Control System.",
order = 35)
public static void deleteAllAclRulesAndMappings() {
deleteAllAclMappings();
MCRRuleStore ruleStore = MCRRuleStore.obtainInstance();
for (String id : ruleStore.retrieveAllIDs()) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("deleting rul {}", id);
}
ruleStore.deleteRule(id);
}
}

/**
* delete all ACL rule mappings
*/
@MCRCommand(syntax = "delete all acl mappings",
help = "Remove all rule mappings from the Access Control System.",
order = 35)
public static void deleteAllAclMappings() {
MCRAccessStore store = MCRAccessStore.obtainInstance();
for (String id : store.getDistinctStringIDs()) {
for (String pool : store.getPoolsForObject(id)) {
MCRRuleMapping rule = store.getAccessDefinition(pool, id);
if (LOGGER.isInfoEnabled()) {
LOGGER.info("deleting rule mapping {} / {} / {}", id, pool, rule.getRuleId());
}
store.deleteAccessDefinition(rule);
}
}
}

/**
* delete the permission {0}
*
Expand Down
Loading