diff --git a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/readonly/ReadOnlyAuthorizationConfiguration.java b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/readonly/ReadOnlyAuthorizationConfiguration.java index e7a5b1510c1..c85c10b41d3 100644 --- a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/readonly/ReadOnlyAuthorizationConfiguration.java +++ b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/readonly/ReadOnlyAuthorizationConfiguration.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.exercise.security.authorization.models.readonly; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy; import org.apache.jackrabbit.commons.iterator.AccessControlPolicyIteratorAdapter; import org.apache.jackrabbit.oak.api.PropertyState; @@ -344,25 +343,25 @@ public RepositoryInitializer getRepositoryInitializer() { @NotNull @Override public List getCommitHooks(@NotNull String workspaceName) { - return ImmutableList.of(); + return List.of(); } @NotNull @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { - return ImmutableList.of(); + return List.of(); } @NotNull @Override public List getConflictHandlers() { - return ImmutableList.of(); + return List.of(); } @NotNull @Override public List getProtectedItemImporters() { - return ImmutableList.of(); + return List.of(); } @NotNull diff --git a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAccessControlManager.java b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAccessControlManager.java index 5303484ef61..2a1216c89e6 100644 --- a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAccessControlManager.java +++ b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAccessControlManager.java @@ -16,6 +16,8 @@ */ package org.apache.jackrabbit.oak.exercise.security.authorization.models.simplifiedroles; +import java.util.List; + import javax.jcr.AccessDeniedException; import javax.jcr.PathNotFoundException; import javax.jcr.RepositoryException; @@ -27,7 +29,6 @@ import javax.jcr.security.Privilege; import javax.jcr.version.VersionException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.commons.iterator.AccessControlPolicyIteratorAdapter; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.spi.security.SecurityProvider; @@ -86,7 +87,7 @@ public AccessControlPolicy[] getEffectivePolicies(String absPath) throws PathNot @Override public AccessControlPolicyIterator getApplicablePolicies(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException { // EXERCISE - return new AccessControlPolicyIteratorAdapter(ImmutableList.of()); + return new AccessControlPolicyIteratorAdapter(List.of()); } @Override diff --git a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAuthorizationConfiguration.java b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAuthorizationConfiguration.java index 0188b15129d..f6be9c8748a 100644 --- a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAuthorizationConfiguration.java +++ b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAuthorizationConfiguration.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.exercise.security.authorization.models.simplifiedroles; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; @@ -168,7 +167,7 @@ public RepositoryInitializer getRepositoryInitializer() { @NotNull @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { - return ImmutableList.of(new ValidatorProvider() { + return List.of(new ValidatorProvider() { @Override protected Validator getRootValidator(NodeState before, NodeState after, CommitInfo info) { // EXERCISE: write a validator that meets the following requirements: @@ -188,7 +187,7 @@ protected Validator getRootValidator(NodeState before, NodeState after, CommitIn @Override public List getProtectedItemImporters() { // EXERCISE - return ImmutableList.of(); + return List.of(); } @NotNull diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java index d443f0d9247..9583db37a3b 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java @@ -27,7 +27,6 @@ import javax.jcr.security.AccessControlPolicy; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; @@ -270,7 +269,7 @@ public void testSessionGetEffectivePoliciesWithoutPrivilege() throws Exception { testSession = getTestSession(); AccessControlManager testAcMgr = testSession.getAccessControlManager(); - List paths = ImmutableList.of(testRoot, NodeTypeConstants.NODE_TYPES_PATH); + List paths = List.of(testRoot, NodeTypeConstants.NODE_TYPES_PATH); for (String path : paths) { // EXERCISE : complete or fix the test case AccessControlPolicy[] effectivePolicies = testAcMgr.getEffectivePolicies(path); diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java index d4d274e9836..46fc6ed6260 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java @@ -17,6 +17,7 @@ package org.apache.jackrabbit.oak.exercise.security.authorization.accesscontrol; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; import java.util.List; import javax.jcr.RepositoryException; @@ -27,7 +28,6 @@ import javax.jcr.security.AccessControlManager; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.JackrabbitWorkspace; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; @@ -186,15 +186,16 @@ public void testUpdateAndComplementary() throws Exception { public void testAddEntryWithInvalidPrincipals() throws Exception { // EXERCISE: explain for each principal in the list why using it for an ACE fails - List invalidPrincipals = ImmutableList.of( + List invalidPrincipals = Arrays.asList( new InvalidTestPrincipal("unknown"), null, - new PrincipalImpl(""), new Principal() { - @Override - public String getName() { - return "unknown"; - } - }); + new PrincipalImpl(""), + new Principal() { + @Override + public String getName() { + return "unknown"; + } + }); for (Principal principal : invalidPrincipals) { try { @@ -227,7 +228,7 @@ public void testAddEntryWithInvalidPrivilege() throws Exception { Privilege customPriv = ((JackrabbitWorkspace) superuser.getWorkspace()).getPrivilegeManager().registerPrivilege(privilegeName, true, new String[0]); // EXERCISE : walks through this test and explain why adding those ACEs fails. - List invalidPrivileges = ImmutableList.of( + List invalidPrivileges = Arrays.asList( new Privilege[0], null, new Privilege[] {customPriv} diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java index 35c9d8076ac..314cb402c9e 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java @@ -23,7 +23,6 @@ import javax.jcr.Session; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.JackrabbitSession; @@ -203,8 +202,7 @@ public void before() throws Exception { root.commit(); - trees = ImmutableList.builder().add(root.getTree("/")).add(testTree).add(aTree).add(aaTree).add(bTree).add(bbTree).add(cTree).add(ccTree).build(); - + trees = List.of(root.getTree("/"), testTree, aTree, aaTree, bTree, bbTree, cTree, ccTree); } private PermissionProvider getPermissionProvider(@NotNull Set principals) { @@ -269,7 +267,7 @@ public void testGuestAccess() throws Exception { @Test public void testWriteAccess() throws Exception { - List> editors = ImmutableList.>of( + List> editors = List.of( ImmutableSet.of(new Editor("ida")), ImmutableSet.of(EveryonePrincipal.getInstance(), new Editor("amanda")), ImmutableSet.of(getTestUser().getPrincipal(),new Editor("susi")), @@ -309,7 +307,7 @@ public void testWriteAccess() throws Exception { @Test public void testReadAccess() throws Exception { - List> readers = ImmutableList.>of( + List> readers = List.of( ImmutableSet.of(new Reader("ida")), ImmutableSet.of(EveryonePrincipal.getInstance(), new Reader("fairuz")), ImmutableSet.of(getTestUser().getPrincipal(),new Editor("juni")), diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java index 8e68990fe6f..b0c980ea456 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.exercise.security.privilege; +import java.util.Arrays; import java.util.Map; import java.util.Set; import javax.jcr.RepositoryException; @@ -23,8 +24,6 @@ import javax.jcr.security.AccessControlPolicy; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; @@ -135,7 +134,7 @@ public void testAggregation() throws RepositoryException { ); Iterable aggregated = Iterables.filter( - ImmutableList.copyOf(privilegeManager.getRegisteredPrivileges()), + Arrays.asList(privilegeManager.getRegisteredPrivileges()), input -> input != null && input.isAggregate()); for (Privilege aggrPrivilege : aggregated) { diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java index 5366a5315de..7724b2f1ecd 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java @@ -20,7 +20,6 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -149,7 +148,7 @@ public void testUserNodeType() throws RepositoryException { String expectedNodeTypeName = null; // EXERCISE assertEquals(expectedNodeTypeName, node.getPrimaryNodeType().getName()); - List mixinTypes = ImmutableList.of(); // EXERCISE : fill the list + List mixinTypes = List.of(); // EXERCISE : fill the list for (String mixin : mixinTypes) { assertTrue(node.isNodeType(mixin)); } @@ -174,7 +173,7 @@ public void testGroupNodeType() throws RepositoryException { String expectedNodeTypeName = null; // EXERCISE assertEquals(expectedNodeTypeName, node.getPrimaryNodeType().getName()); - List mixinTypes = ImmutableList.of(); // EXERCISE : fill the list + List mixinTypes = List.of(); // EXERCISE : fill the list for (String mixin : mixinTypes) { assertTrue(node.isNodeType(mixin)); } diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java index 1b8ea63c0f5..c1e9f2d2137 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java @@ -22,7 +22,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -125,7 +124,7 @@ public void testArbitraryProperties() throws RepositoryException { Node node = getAuthorizableNode(testUser); // EXERCISE: build the list of existing user properties rel paths - List userPropertiesPath = ImmutableList.of(); + List userPropertiesPath = List.of(); for (String relPath : userPropertiesPath) { assertTrue(testUser.hasProperty(relPath)); } @@ -139,13 +138,13 @@ public void testArbitraryProperties() throws RepositoryException { assertArrayEquals(petsExpected, node.getProperty(expectedRelPath).getValues()); // EXERCISE: build a list of protected JCR properties that cannot be accessed using the Authorizable interface - List protectedJcrPropertyNames = ImmutableList.of(); + List protectedJcrPropertyNames = List.of(); for (String relPath : protectedJcrPropertyNames) { assertFalse(testUser.hasProperty(relPath)); } // EXERCISE: build a list of protected properties defined by the authorizable or user node type definitions that cannot be accessed using the Authorizable interface - List protectedAuthorizablePropertyNames = ImmutableList.of(); + List protectedAuthorizablePropertyNames = List.of(); for (String relPath : protectedAuthorizablePropertyNames) { assertFalse(testUser.hasProperty(relPath)); }