You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2024/12/02 10:57:09 UTC
(jackrabbit-oak) branch OAK-11288 updated: OAK-11288: remove usage of Immutable.Map.builder() - oak-auth-external
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch OAK-11288
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/OAK-11288 by this push:
new 4f05bf4094 OAK-11288: remove usage of Immutable.Map.builder() - oak-auth-external
4f05bf4094 is described below
commit 4f05bf4094f4dbddd4db9aade4829cda859e45af
Author: Julian Reschke <re...@apache.org>
AuthorDate: Mon Dec 2 11:56:57 2024 +0100
OAK-11288: remove usage of Immutable.Map.builder() - oak-auth-external
---
.../ExternalIdentityValidatorProvider.java | 15 +++++-----
.../external/AbstractExternalAuthTest.java | 19 ++++++-------
.../external/impl/jmx/DelegateeTest.java | 33 +++++++++++-----------
.../ExternalPrincipalConfigurationTest.java | 6 ++--
4 files changed, 35 insertions(+), 38 deletions(-)
diff --git a/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorProvider.java b/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorProvider.java
index 04d7d88582..f20bf47873 100644
--- a/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorProvider.java
+++ b/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorProvider.java
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
@@ -40,13 +39,13 @@ import java.util.Map;
*/
class ExternalIdentityValidatorProvider extends ValidatorProvider implements ExternalIdentityConstants {
- private static final Map<Integer, String> ERROR_MSGS = ImmutableMap.<Integer, String>builder()
- .put(70, "Attempt to create, modify or remove the system property 'rep:externalPrincipalNames'")
- .put(71, "Property 'rep:externalPrincipalNames' must be multi-valued of type STRING.")
- .put(72, "Property 'rep:externalPrincipalNames' requires 'rep:externalId' to be present on the Node.")
- .put(73, "Property 'rep:externalId' cannot be removed as long as 'rep:externalPrincipalNames' is present.")
- .put(74, "Attempt to add, modify or remove the system maintained property 'rep:externalId'.")
- .put(75, "Property 'rep:externalId' may only have a single value of type STRING.").build();
+ private static final Map<Integer, String> ERROR_MSGS = Map.of(
+ 70, "Attempt to create, modify or remove the system property 'rep:externalPrincipalNames'",
+ 71, "Property 'rep:externalPrincipalNames' must be multi-valued of type STRING.",
+ 72, "Property 'rep:externalPrincipalNames' requires 'rep:externalId' to be present on the Node.",
+ 73, "Property 'rep:externalId' cannot be removed as long as 'rep:externalPrincipalNames' is present.",
+ 74, "Attempt to add, modify or remove the system maintained property 'rep:externalId'.",
+ 75, "Property 'rep:externalId' may only have a single value of type STRING.");
private final boolean isSystem;
private final boolean protectedExternalIds;
diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/AbstractExternalAuthTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/AbstractExternalAuthTest.java
index 9a9e193533..3fdc930c3a 100644
--- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/AbstractExternalAuthTest.java
+++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/AbstractExternalAuthTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external;
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.User;
@@ -199,16 +198,16 @@ public abstract class AbstractExternalAuthTest extends AbstractSecurityTest {
));
return (DefaultSyncHandler) context.registerService(SyncHandler.class, new DefaultSyncHandler(), syncConfigMap);
}
-
+
protected @NotNull Map<String, Object> syncConfigAsMap() {
- ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
- builder.put(DefaultSyncConfigImpl.PARAM_NAME, syncConfig.getName())
- .put(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, syncConfig.user().getDynamicMembership())
- .put(DefaultSyncConfigImpl.PARAM_USER_MEMBERSHIP_NESTING_DEPTH, syncConfig.user().getMembershipNestingDepth())
- .put(DefaultSyncConfigImpl.PARAM_USER_AUTO_MEMBERSHIP, syncConfig.user().getAutoMembership().toArray(new String[0]))
- .put(DefaultSyncConfigImpl.PARAM_GROUP_AUTO_MEMBERSHIP, syncConfig.group().getAutoMembership().toArray(new String[0]))
- .put(DefaultSyncConfigImpl.PARAM_GROUP_DYNAMIC_GROUPS, syncConfig.group().getDynamicGroups());
- return builder.build();
+ Map<String, Object> builder = Map.of(
+ DefaultSyncConfigImpl.PARAM_NAME, syncConfig.getName(),
+ DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, syncConfig.user().getDynamicMembership(),
+ DefaultSyncConfigImpl.PARAM_USER_MEMBERSHIP_NESTING_DEPTH, syncConfig.user().getMembershipNestingDepth(),
+ DefaultSyncConfigImpl.PARAM_USER_AUTO_MEMBERSHIP, syncConfig.user().getAutoMembership().toArray(new String[0]),
+ DefaultSyncConfigImpl.PARAM_GROUP_AUTO_MEMBERSHIP, syncConfig.group().getAutoMembership().toArray(new String[0]),
+ DefaultSyncConfigImpl.PARAM_GROUP_DYNAMIC_GROUPS, syncConfig.group().getDynamicGroups());
+ return Collections.unmodifiableMap(builder);
}
@NotNull
diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/jmx/DelegateeTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/jmx/DelegateeTest.java
index 5eb99d53c1..604edc721b 100644
--- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/jmx/DelegateeTest.java
+++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/jmx/DelegateeTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.jmx;
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.jackrabbit.oak.api.AuthInfo;
@@ -221,14 +220,14 @@ public class DelegateeTest extends AbstractJmxTest {
Root r = preventRootCommit(delegatee);
- ImmutableMap<String, String> expected = ImmutableMap.<String, String>builder()
- .put(ID_TEST_USER, "ERR")
- .put("a", "ERR")
- .put("b", "ERR")
- .put("c", "ERR")
- .put(TestIdentityProvider.ID_SECOND_USER, "ERR")
- .put("secondGroup", "ERR")
- .put("third", "mis").build();
+ Map<String, String> expected = Map.of(
+ ID_TEST_USER, "ERR",
+ "a", "ERR",
+ "b", "ERR",
+ "c", "ERR",
+ TestIdentityProvider.ID_SECOND_USER, "ERR",
+ "secondGroup", "ERR",
+ "third", "mis");
String[] result = delegatee.syncAllUsers(false);
assertResultMessages(result, expected);
@@ -245,14 +244,14 @@ public class DelegateeTest extends AbstractJmxTest {
Root r = preventRootCommit(delegatee);
- ImmutableMap<String, String> expected = ImmutableMap.<String, String>builder()
- .put(ID_TEST_USER, "ERR")
- .put("a", "ERR")
- .put("b", "ERR")
- .put("c", "ERR")
- .put(TestIdentityProvider.ID_SECOND_USER, "ERR")
- .put("secondGroup", "ERR")
- .put("third", "ERR").build();
+ Map<String, String> expected = Map.of(
+ ID_TEST_USER, "ERR",
+ "a", "ERR",
+ "b", "ERR",
+ "c", "ERR",
+ TestIdentityProvider.ID_SECOND_USER, "ERR",
+ "secondGroup", "ERR",
+ "third", "ERR");
String[] result = delegatee.syncAllUsers(true);
assertResultMessages(result, expected);
diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalPrincipalConfigurationTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalPrincipalConfigurationTest.java
index 3260c5800c..946490a6d3 100644
--- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalPrincipalConfigurationTest.java
+++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalPrincipalConfigurationTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.jackrabbit.oak.api.ContentSession;
@@ -62,6 +61,7 @@ import java.lang.reflect.Field;
import java.security.Principal;
import java.util.Collections;
import java.util.Dictionary;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -86,7 +86,7 @@ public class ExternalPrincipalConfigurationTest extends AbstractExternalAuthTest
}
private void registerSyncHandler(boolean dynamicMembership, boolean dynamicGroups) {
- ImmutableMap.Builder<String, Object> config = new ImmutableMap.Builder<>();
+ Map<String, Object> config = new HashMap<>();
config.put(DefaultSyncConfigImpl.PARAM_NAME, DefaultSyncConfig.DEFAULT_NAME);
if (dynamicMembership) {
config.put(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, true);
@@ -94,7 +94,7 @@ public class ExternalPrincipalConfigurationTest extends AbstractExternalAuthTest
if (dynamicGroups) {
config.put(DefaultSyncConfigImpl.PARAM_GROUP_DYNAMIC_GROUPS, true);
}
- registerSyncHandler(config.build(), idp.getName());
+ registerSyncHandler(Collections.unmodifiableMap(config), idp.getName());
}
private void assertIsEnabled(ExternalPrincipalConfiguration externalPrincipalConfiguration, boolean expected) {