|
36 | 36 | import org.jdom2.output.XMLOutputter; |
37 | 37 | import org.mycore.access.MCRAccessManager; |
38 | 38 | import org.mycore.access.MCRRuleAccessInterface; |
| 39 | +import org.mycore.access.mcrimpl.MCRAccessStore; |
| 40 | +import org.mycore.access.mcrimpl.MCRRuleMapping; |
| 41 | +import org.mycore.access.mcrimpl.MCRRuleStore; |
39 | 42 | import org.mycore.common.MCRException; |
40 | 43 | import org.mycore.common.config.MCRConfiguration2; |
41 | 44 | import org.mycore.common.xsl.uriresolver.MCRURIResolver; |
@@ -155,6 +158,34 @@ public static void deleteAllPermissions() { |
155 | 158 | } |
156 | 159 | } |
157 | 160 |
|
| 161 | + /** |
| 162 | + * delete all permissions and rules |
| 163 | + * {@link #permissionUpdateForID(String, String, String)} and |
| 164 | + * {@link #permissionFileUpdateForID(String, String, String)} |
| 165 | + */ |
| 166 | + @MCRCommand(syntax = "delete all acl rules and mappings", |
| 167 | + help = "Remove all permission and rule entries from the Access Control System.", |
| 168 | + order = 35) |
| 169 | + public static void deleteAllAclRulesAndMappings() { |
| 170 | + MCRAccessStore accessStore = MCRAccessStore.obtainInstance(); |
| 171 | + Collection<String> accessIds = accessStore.getDistinctStringIDs(); |
| 172 | + for (String accessId : accessIds) { |
| 173 | + Collection<String> pools = accessStore.getPoolsForObject(accessId); |
| 174 | + for (String pool : pools) { |
| 175 | + MCRRuleMapping rule = accessStore.getAccessDefinition(pool, accessId); |
| 176 | + if (LOGGER.isInfoEnabled()) { |
| 177 | + LOGGER.info("deleting {} / {} / {}", accessId, pool, rule.getRuleId()); |
| 178 | + } |
| 179 | + accessStore.deleteAccessDefinition(rule); |
| 180 | + } |
| 181 | + } |
| 182 | + MCRRuleStore ruleStore = MCRRuleStore.obtainInstance(); |
| 183 | + Collection<String> ruleIds = ruleStore.retrieveAllIDs(); |
| 184 | + for (String ruleId : ruleIds) { |
| 185 | + ruleStore.deleteRule(ruleId); |
| 186 | + } |
| 187 | + } |
| 188 | + |
158 | 189 | /** |
159 | 190 | * delete the permission {0} |
160 | 191 | * |
|
0 commit comments