Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -17,11 +17,10 @@
package org.apache.jackrabbit.oak.spi.security.authentication.external;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;
Expand Down Expand Up @@ -169,7 +168,7 @@ public Iterable<ExternalIdentityRef> getDeclaredGroups() {

@Test
public void testToString() {
for (ExternalIdentityRef r : ImmutableList.of(ref, refEmptyProvider, refEmptyProvider)) {
for (ExternalIdentityRef r : List.of(ref, refEmptyProvider, refEmptyProvider)) {
assertEquals("ExternalIdentityRef{" + "id='" + r.getId() + '\'' + ", providerName='" + r.getProviderName() + '\'' + '}', r.toString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
Expand All @@ -29,8 +30,6 @@
import javax.jcr.SimpleCredentials;
import javax.security.auth.login.LoginException;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;

import org.jetbrains.annotations.NotNull;

public class TestIdentityProvider implements ExternalIdentityProvider {
Expand Down Expand Up @@ -75,7 +74,7 @@ public TestIdentityProvider(@NotNull String idpName) {
addUser(new TestUser(ID_SECOND_USER, getName())
.withProperty("profile/name", "Second User")
.withProperty("age", 24)
.withProperty("col", ImmutableList.of("v1", "v2", "v3"))
.withProperty("col", List.of("v1", "v2", "v3"))
.withProperty("boolArr", new Boolean[]{true, false})
.withProperty("charArr", new char[]{'t', 'o', 'b'})
.withProperty("byteArr", new byte[0])
Expand Down Expand Up @@ -283,7 +282,7 @@ public ForeignExternalGroup() {
@NotNull
@Override
public Iterable<ExternalIdentityRef> getDeclaredMembers() {
return ImmutableList.of();
return List.of();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.basic;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.Group;
Expand Down Expand Up @@ -1451,7 +1450,7 @@ public void testCreateValueFromInputStream() throws Exception {

@Test
public void testCreateValuesEmptyCollection() throws Exception {
Value[] vs = syncCtx.createValues(ImmutableList.of());
Value[] vs = syncCtx.createValues(List.of());
assertNotNull(vs);
assertEquals(0, vs.length);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser;
Expand All @@ -36,6 +35,7 @@
import java.security.Principal;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

import static org.junit.Assert.assertSame;

Expand Down Expand Up @@ -116,17 +116,17 @@ protected void sync(@NotNull ExternalIdentity externalIdentity, @NotNull SyncRes

@NotNull
static List<String> getIds(@NotNull Iterator<? extends Authorizable> authorizables) {
return ImmutableList.copyOf(Iterators.transform(authorizables, authorizable -> {
return CollectionUtils.toStream(authorizables).map(authorizable -> {
try {
return authorizable.getID();
} catch (RepositoryException repositoryException) {
throw new RuntimeException();
}
}));
}).collect(Collectors.toList());
}

@NotNull
static List<String> getPrincipalNames(@NotNull Iterator<Principal> groupPrincipals) {
return ImmutableList.copyOf(Iterators.transform(groupPrincipals, Principal::getName));
return CollectionUtils.toStream(groupPrincipals).map(Principal::getName).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import javax.jcr.SimpleCredentials;
import javax.security.auth.login.LoginException;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.api.AuthInfo;
import org.apache.jackrabbit.oak.api.ContentSession;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup;
Expand Down Expand Up @@ -71,7 +70,7 @@ public void testLogin() throws Exception {

@Test
public void testLoginWithUnsupportedCredentials() throws Exception {
List<Credentials> creds = ImmutableList.of(
List<Credentials> creds = List.of(
new SimpleCredentials("testUser", new char[0]),
new GuestCredentials());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
import org.apache.jackrabbit.api.security.principal.PrincipalManager;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.Group;
import org.apache.jackrabbit.api.security.user.User;
import org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProvider;
Expand Down Expand Up @@ -294,7 +292,7 @@ public void testCrossIDPMembership() throws Exception {
UserManager um = getUserManager(r);
PrincipalManager pm = getPrincipalManager(r);

List<ExternalIdentityRef> declaredGroupRefs = ImmutableList.copyOf(previouslySyncedUser.getDeclaredGroups());
List<ExternalIdentityRef> declaredGroupRefs = CollectionUtils.toList(previouslySyncedUser.getDeclaredGroups());
assertTrue(declaredGroupRefs.size() > 1);

String groupId = declaredGroupRefs.get(0).getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.api.security.user.Authorizable;
Expand Down Expand Up @@ -47,6 +46,7 @@

import javax.jcr.RepositoryException;
import javax.jcr.Value;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -119,7 +119,7 @@ protected void assertDynamicMembership(@NotNull ExternalIdentity externalIdentit

private void assertDynamicMembership(@NotNull Authorizable a, @NotNull ExternalIdentity externalIdentity, long depth) throws Exception {
Value[] vs = a.getProperty(REP_EXTERNAL_PRINCIPAL_NAMES);
Set<String> pNames = ImmutableList.copyOf(vs).stream().map(value -> {
Set<String> pNames = Arrays.stream(vs).map(value -> {
try {
return value.getString();
} catch (RepositoryException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.api.security.user.Group;
import org.apache.jackrabbit.api.security.user.User;
Expand Down Expand Up @@ -141,7 +140,7 @@ public void testAddMembersProperty() throws Exception {
assertFalse(groupTree.hasProperty(REP_MEMBERS));

String uuid = r.getTree(userManager.getAuthorizable(USER_ID).getPath()).getProperty(JCR_UUID).getValue(Type.STRING);
groupTree.setProperty(REP_MEMBERS, ImmutableList.of(uuid), Type.WEAKREFERENCES);
groupTree.setProperty(REP_MEMBERS, List.of(uuid), Type.WEAKREFERENCES);
try {
r.commit();
fail("CommitFailedException 77 expected.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.api.security.principal.GroupPrincipal;
import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
import org.apache.jackrabbit.api.security.principal.PrincipalManager;
Expand Down Expand Up @@ -586,7 +585,7 @@ public Iterator<? extends Principal> findPrincipals(@Nullable String nameHint, i
return in.iterator();
}
};
List<Principal> out = ImmutableList.copyOf(p.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1));
List<Principal> out = CollectionUtils.toList(p.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1));
Collections.sort(in, Comparator.comparing(Principal::getName));
assertEquals(in, out);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.api.security.principal.GroupPrincipal;
import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
Expand All @@ -26,6 +25,7 @@
import org.apache.jackrabbit.oak.api.QueryEngine;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser;
Expand All @@ -38,7 +38,9 @@
import java.security.Principal;
import java.text.ParseException;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.apache.jackrabbit.oak.spi.security.authentication.external.TestIdentityProvider.ID_SECOND_USER;
import static org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES;
Expand Down Expand Up @@ -69,18 +71,19 @@ public void testNotIsMember() throws Exception {
Authorizable notMember = getUserManager(root).getAuthorizable(ID_SECOND_USER);
assertFalse(principal.isMember(notMember.getPrincipal()));

root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("secondGroup"), Type.STRINGS);
root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, List.of("secondGroup"), Type.STRINGS);
assertFalse(principal.isMember(notMember.getPrincipal()));

root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of(), Type.STRINGS);
root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, List.of(), Type.STRINGS);
assertFalse(principal.isMember(new PrincipalImpl(notMember.getPrincipal().getName())));
}

@Test
public void testIsMemberExternalGroup() throws Exception {
GroupPrincipal principal = getGroupPrincipal();

Iterable<String> exGroupPrincNames = Iterables.transform(ImmutableList.copyOf(idp.listGroups()), ExternalIdentity::getPrincipalName);
List<String> exGroupPrincNames = CollectionUtils.toStream(
idp.listGroups()).map(ExternalIdentity::getPrincipalName).collect(Collectors.toList());
for (String principalName : exGroupPrincNames) {
assertFalse(principal.isMember(new PrincipalImpl(principalName)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import javax.jcr.SimpleCredentials;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.User;
import org.apache.jackrabbit.oak.api.CommitFailedException;
Expand Down Expand Up @@ -85,7 +84,7 @@ protected boolean isDynamic() {
public void testAddExternalPrincipalNames() throws Exception {
Tree userTree = root.getTree(testUserPath);
try {
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS);
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS);
root.commit();
fail("Creating rep:externalPrincipalNames must be detected.");
} catch (CommitFailedException e) {
Expand All @@ -101,7 +100,7 @@ public void testAddExternalPrincipalNamesAsSystemMissingExternalId() throws Exce
Root systemRoot = getSystemRoot();
try {
Tree userTree = systemRoot.getTree(testUserPath);
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS);
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS);
systemRoot.commit();
fail("Creating rep:externalPrincipalNames without rep:externalId must be detected.");
} catch (CommitFailedException e) {
Expand All @@ -117,7 +116,7 @@ public void testAddExternalPrincipalNamesAsSystem() throws Exception {
Root systemRoot = getSystemRoot();
Tree userTree = systemRoot.getTree(testUserPath);
userTree.setProperty(REP_EXTERNAL_ID, "externalId");
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS);
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS);
systemRoot.commit();
}

Expand Down Expand Up @@ -167,7 +166,7 @@ public void testModifyExternalPrincipalNamesAsSystem() throws Exception {
Tree userTree = systemRoot.getTree(externalUserPath);

// changing with system root must succeed
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalNames"), Type.STRINGS);
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalNames"), Type.STRINGS);
systemRoot.commit();
}

Expand Down Expand Up @@ -233,7 +232,7 @@ public void testRepExternalIdMultiple() throws Exception {
Root systemRoot = getSystemRoot();
try {
Tree userTree = systemRoot.getTree(testUserPath);
userTree.setProperty(REP_EXTERNAL_ID, ImmutableList.of("id", "id2"), Type.STRINGS);
userTree.setProperty(REP_EXTERNAL_ID, List.of("id", "id2"), Type.STRINGS);
systemRoot.commit();
fail("Creating rep:externalId as multiple STRING property must be detected.");
} catch (CommitFailedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.api.security.principal.GroupPrincipal;
import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
Expand Down Expand Up @@ -300,7 +299,7 @@ public void testGetPrincipals() throws Exception {

@Test
public void testFindPrincipalsByHint() throws Exception {
List<String> hints = ImmutableList.of(
List<String> hints = List.of(
USER_AUTO_MEMBERSHIP_GROUP_PRINCIPAL_NAME,
GROUP_AUTO_MEMBERSHIP_GROUP_PRINCIPAL_NAME,
USER_AUTO_MEMBERSHIP_GROUP_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;

import java.util.List;
import java.util.Map;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.api.Type;
Expand All @@ -41,7 +41,7 @@ public void before() throws Exception {
public void testRepExternalIdMultiple() throws Exception {
Root systemRoot = getSystemRoot();
Tree userTree = systemRoot.getTree(testUserPath);
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_ID, ImmutableList.of("id", "id2"), Type.STRINGS);
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_ID, List.of("id", "id2"), Type.STRINGS);
systemRoot.commit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalIdentityConstants;
import org.junit.Test;

import java.util.List;

import static org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT;
import static org.junit.Assert.fail;

Expand All @@ -41,7 +42,7 @@ protected boolean isDynamic() {

private void setExternalPrincipalNames() throws Exception {
Root systemRoot = getSystemRoot();
systemRoot.getTree(externalUserPath).setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS);
systemRoot.getTree(externalUserPath).setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS);
systemRoot.commit();

root.refresh();
Expand Down
Loading