Skip to content

Commit 8fbe9fa

Browse files
committed
merge branch 'trunk' into OAK-11448
2 parents 79e431d + 16aaa6e commit 8fbe9fa

File tree

52 files changed

+248
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+248
-106
lines changed

oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import javax.jcr.RepositoryException;
3939
import javax.jcr.Value;
4040
import javax.jcr.query.Query;
41+
42+
import org.apache.commons.collections4.IterableUtils;
4143
import org.apache.jackrabbit.api.security.principal.GroupPrincipal;
4244
import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
4345
import org.apache.jackrabbit.api.security.principal.PrincipalManager;
@@ -608,7 +610,7 @@ private boolean isContainedInExternalPrincipalNames(@NotNull Principal member) t
608610
Tree tree = root.getTree(((ItemBasedPrincipal) member).getPath());
609611
if (UserUtil.isType(tree, AuthorizableType.USER)) {
610612
PropertyState ps = tree.getProperty(REP_EXTERNAL_PRINCIPAL_NAMES);
611-
return (ps != null && Iterables.contains(ps.getValue(Type.STRINGS), name));
613+
return (ps != null && IterableUtils.contains(ps.getValue(Type.STRINGS), name));
612614
}
613615
} else {
614616
Authorizable a = userManager.getAuthorizable(member);

oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncContextTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.jackrabbit.oak.spi.security.authentication.external.basic;
1818

19+
import org.apache.commons.collections4.IterableUtils;
1920
import org.apache.jackrabbit.guava.common.collect.Iterables;
2021
import org.apache.jackrabbit.api.security.user.Authorizable;
2122
import org.apache.jackrabbit.api.security.user.Group;
@@ -904,7 +905,7 @@ public void testSyncMembershipDepthInfinite() throws Exception {
904905
for (ExternalIdentityRef inheritedGrRef : extGr.getDeclaredGroups()) {
905906
Group g = userManager.getAuthorizable(inheritedGrRef.getId(), Group.class);
906907
assertNotNull(g);
907-
if (Iterables.contains(externalUser.getDeclaredGroups(), inheritedGrRef)) {
908+
if (IterableUtils.contains(externalUser.getDeclaredGroups(), inheritedGrRef)) {
908909
assertTrue(g.isDeclaredMember(a));
909910
} else {
910911
assertFalse(g.isDeclaredMember(a));

oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void assertSyncedMembership(@NotNull UserManager userManager,
164164
List<String> ids = getIds(a.memberOf());
165165
assertTrue("Expected "+ids+ " to contain "+gr.getID(), ids.contains(gr.getID()));
166166

167-
if (Iterables.contains(declaredGroupRefs, ref)) {
167+
if (IterableUtils.contains(declaredGroupRefs, ref)) {
168168
assertTrue(gr.isDeclaredMember(a));
169169
assertTrue(Iterators.contains(a.declaredMemberOf(), gr));
170170
}
@@ -203,7 +203,7 @@ static boolean hasStoredMembershipInformation(@NotNull Tree groupTree, @NotNull
203203

204204
private static boolean containsMemberRef(@NotNull Tree tree, @NotNull String ref) {
205205
Iterable<String> memberRefs = TreeUtil.getStrings(tree, REP_MEMBERS);
206-
return memberRefs != null && Iterables.contains(memberRefs, ref);
206+
return memberRefs != null && IterableUtils.contains(memberRefs, ref);
207207
}
208208

209209
@Test(expected = IllegalArgumentException.class)

oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ private Set<String> collectEffectiveCandidates(@NotNull Root r, @NotNull Iterabl
367367
String path = eval.remove();
368368
Tree t = immutableRoot.getTree(path);
369369
if (PathUtils.denotesRoot(path)) {
370-
Iterables.addAll(eval, nestedCugPaths(t));
370+
nestedCugPaths(t).forEach(eval::add);
371371
}
372372
if (CugUtil.isSupportedPath(path, supportedPaths)) {
373373
Tree cug = CugUtil.getCug(t);
@@ -376,7 +376,7 @@ private Set<String> collectEffectiveCandidates(@NotNull Root r, @NotNull Iterabl
376376
if (!Collections.disjoint(SetUtils.toSet(principalNames), SetUtils.toSet(pNames.getValue(Type.STRINGS)))) {
377377
candidates.add(path);
378378
}
379-
Iterables.addAll(eval, nestedCugPaths(cug));
379+
nestedCugPaths(cug).forEach(eval::add);
380380
}
381381
}
382382
}

oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHook.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ private boolean processDiff(@NotNull Diff diff, @NotNull Set<String> reconnect)
325325
// parent CUG got removed -> no removal/reconnect required if current path is listed.
326326
NodeState cugNode = diff.beforeState.getChildNode(REP_CUG_POLICY);
327327
PropertyState ps = cugNode.getProperty(HIDDEN_NESTED_CUGS);
328-
if (ps != null && Iterables.contains(ps.getValue(Type.STRINGS), path)) {
328+
if (ps != null && IterableUtils.contains(ps.getValue(Type.STRINGS), path)) {
329329
log.debug("Nested cug property containing {} has also been removed; no reconnect required.", path);
330330
return true;
331331
}

oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugPolicyImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,14 @@ public void testAddExcludedPrincipal() throws Exception {
266266

267267
Principal excluded = getExcludedPrincipal();
268268
assertTrue(cug.addPrincipals(EveryonePrincipal.getInstance(), excluded));
269-
assertFalse(Iterables.contains(cug.getPrincipalNames(), excluded.getName()));
269+
assertFalse(IterableUtils.contains(cug.getPrincipalNames(), excluded.getName()));
270270
}
271271

272272
@Test
273273
public void testExcludedPrincipalAddedBefore() {
274274
Principal excluded = getExcludedPrincipal();
275275
CugPolicyImpl cug = createCugPolicy(ImportBehavior.ABORT, Collections.singleton(excluded));
276-
assertTrue(Iterables.contains(cug.getPrincipalNames(), excluded.getName()));
276+
assertTrue(IterableUtils.contains(cug.getPrincipalNames(), excluded.getName()));
277277
}
278278

279279
@Test

oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl;
1818

19+
import org.apache.commons.collections4.IterableUtils;
1920
import org.apache.jackrabbit.guava.common.collect.Iterables;
2021
import org.apache.jackrabbit.JcrConstants;
2122
import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
@@ -265,7 +266,7 @@ public void tetPolicyChildAddedWrongType() {
265266
@Test
266267
public void tetPolicyChildAddedMissingMixinOnParent() {
267268
NodeState rootState = getTreeProvider().asNodeState(root.getTree(PathUtils.ROOT_PATH));
268-
assertFalse(Iterables.contains(rootState.getNames(JcrConstants.JCR_MIXINTYPES), MIX_REP_PRINCIPAL_BASED_MIXIN));
269+
assertFalse(IterableUtils.contains(rootState.getNames(JcrConstants.JCR_MIXINTYPES), MIX_REP_PRINCIPAL_BASED_MIXIN));
269270

270271
NodeState child = mockNodeState(NT_REP_PRINCIPAL_POLICY);
271272
try {

oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsAccessControlTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void before() throws Exception {
7373
readablePaths = Iterators.cycle(Iterables.transform(paths, f -> getNamePathMapper().getJcrPath(f)));
7474
Set<String> childPaths = new HashSet<>();
7575
for (String path : paths) {
76-
Iterables.addAll(childPaths, Iterables.transform(root.getTree(path).getChildren(), tree -> getNamePathMapper().getJcrPath(tree.getPath())));
76+
Iterables.transform(root.getTree(path).getChildren(), tree -> getNamePathMapper().getJcrPath(tree.getPath())).forEach(childPaths::add);
7777
}
7878
readableChildPaths = Iterators.cycle(childPaths);
7979
}

oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsPermissionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void before() throws Exception {
6464
readablePaths = Iterators.cycle(paths);
6565
Set<String> childPaths = new HashSet<>();
6666
for (String path : paths) {
67-
Iterables.addAll(childPaths, Iterables.transform(root.getTree(path).getChildren(), Tree::getPath));
67+
Iterables.transform(root.getTree(path).getChildren(), Tree::getPath).forEach(childPaths::add);
6868
}
6969
readableChildPaths = Iterators.cycle(childPaths);
7070

oak-core-spi/src/main/java/org/apache/jackrabbit/oak/namepath/NameMapper.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,35 @@ public interface NameMapper {
6363
Map<String, String> getSessionLocalMappings();
6464

6565
/**
66-
* Returns the JCR name for the given Oak name. The given name is
66+
* Returns the JCR name in qualified form for the given Oak name. The given name is
6767
* expected to have come from a valid Oak repository that contains
6868
* only valid names with proper namespace mappings. If that's not
6969
* the case, either a programming error or a repository corruption
7070
* has occurred and an appropriate unchecked exception gets thrown.
7171
*
7272
* @param oakName Oak name
73-
* @return JCR name
73+
* @return JCR name in qualified form
74+
*
75+
* @see <a href="https://s.apache.org/jcr-2.0-spec/3_Repository_Model.html#3.2.5.2%20Qualified%20Form">JCR 2.0, 3.2.5.2 Qualifed Form</a>
7476
*/
7577
@NotNull
7678
String getJcrName(@NotNull String oakName);
7779

80+
/**
81+
* Returns the JCR name in expanded form for the given Oak name. The given name is
82+
* expected to have come from a valid Oak repository that contains
83+
* only valid names with proper namespace mappings. If that's not
84+
* the case, either a programming error or a repository corruption
85+
* has occurred and an appropriate unchecked exception gets thrown.
86+
*
87+
* @param oakName Oak name
88+
* @return JCR name in expanded form
89+
* @since Oak 1.76.0
90+
* @throws IllegalStateException in case the namespace URI for the given Oak name cannot be resolved
91+
*
92+
* @see <a href="https://s.apache.org/jcr-2.0-spec/3_Repository_Model.html#3.2.5.1%20Expanded%20Form">JCR 2.0, 3.2.5.1 Expanded Form</a>
93+
*/
94+
@NotNull
95+
String getExpandedJcrName(@NotNull String oakName);
96+
7897
}

0 commit comments

Comments
 (0)