Skip to content

Commit a29cb18

Browse files
committed
Do not pre-validate restrictions
Oak takes care of that in https://github.com/apache/jackrabbit-oak/blob/17281282fe82d0f0c4e86d0a42ecfb20bfe404e3/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ACL.java#L213 as soon as you try to apply those. Otherwise you face exceptions when using restrictions only available at run-time in cloud (but not at build time). This closes #854
1 parent 8fdc6ba commit a29cb18

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/aceinstaller/BaseAceBeanInstaller.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818

1919
import java.security.Principal;
2020
import java.util.Arrays;
21-
import java.util.Collection;
2221
import java.util.Collections;
2322
import java.util.HashSet;
24-
import java.util.List;
2523
import java.util.Map;
2624
import java.util.Set;
2725
import java.util.TreeSet;
@@ -41,7 +39,6 @@
4139
import biz.netcentric.cq.tools.actool.comparators.AcePermissionComparator;
4240
import biz.netcentric.cq.tools.actool.configmodel.AcConfiguration;
4341
import biz.netcentric.cq.tools.actool.configmodel.AceBean;
44-
import biz.netcentric.cq.tools.actool.configmodel.Restriction;
4542
import biz.netcentric.cq.tools.actool.helper.AccessControlUtils;
4643
import biz.netcentric.cq.tools.actool.helper.ContentHelper;
4744
import biz.netcentric.cq.tools.actool.helper.RestrictionsHolder;
@@ -168,25 +165,15 @@ protected boolean installPrivileges(AceBean aceBean, Principal principal, Jackra
168165
* @throws UnsupportedRepositoryOperationException
169166
* @throws RepositoryException */
170167
protected RestrictionsHolder getRestrictions(AceBean aceBean, Session session, JackrabbitAccessControlList acl)
171-
throws ValueFormatException, UnsupportedRepositoryOperationException, RepositoryException {
172-
173-
final Collection<String> supportedRestrictionNames = Arrays.asList(acl.getRestrictionNames());
168+
throws RepositoryException {
174169

175170
if (aceBean.getRestrictions().isEmpty()) {
176171
return RestrictionsHolder.empty();
177172
}
178-
179-
List<Restriction> restrictions = aceBean.getRestrictions();
180-
for (Restriction restriction : restrictions) {
181-
if (!supportedRestrictionNames.contains(restriction.getName())) {
182-
throw new IllegalStateException(
183-
"The AccessControlList at " + acl.getPath() + " does not support setting " + restriction.getName()
184-
+ " restrictions!");
185-
}
186-
}
187-
188-
RestrictionsHolder restrictionsHolder = new RestrictionsHolder(restrictions, session.getValueFactory(), acl);
189-
return restrictionsHolder;
173+
// no need to check if restrictions are supported, Oak is lenient nowadays and does the proper checks internally
174+
// see https://github.com/apache/jackrabbit-oak/blob/17281282fe82d0f0c4e86d0a42ecfb20bfe404e3/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ACL.java#L213
175+
// also it supports non-mandatory restrictions like the ones from com.adobe.cq.dam.assetmetadatarestrictionprovider.impl.AssetMetadataRestrictionProvider
176+
return new RestrictionsHolder(aceBean.getRestrictions(), session.getValueFactory(), acl);
190177
}
191178

192179
/** Converts the given privilege names into a set of privilege objects.

0 commit comments

Comments
 (0)