From 1a227212deaf7b933cebc0100cb44871644c7ee5 Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Tue, 24 May 2022 10:32:56 +0200 Subject: [PATCH] Simplify implementation of a federated storage by moving the default implementation to the abstract base class; this will also allow the quickstarts and implementations derived from that to run without changes. --- .../adapter/AbstractUserAdapterFederatedStorage.java | 7 +++++++ .../federation/BackwardsCompatibilityUserStorage.java | 5 ----- .../PassThroughFederatedUserStorageProvider.java | 5 ----- .../org/keycloak/testsuite/federation/UserMapStorage.java | 5 ----- .../testsuite/federation/UserPropertyFileStorage.java | 5 ----- 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapterFederatedStorage.java b/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapterFederatedStorage.java index 3ebd181a76..d7756a3042 100644 --- a/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapterFederatedStorage.java +++ b/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapterFederatedStorage.java @@ -18,11 +18,13 @@ package org.keycloak.storage.adapter; import org.keycloak.common.util.MultivaluedHashMap; import org.keycloak.component.ComponentModel; +import org.keycloak.credential.LegacySingleUserCredentialManager; import org.keycloak.models.ClientModel; import org.keycloak.models.GroupModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; import org.keycloak.models.RoleModel; +import org.keycloak.models.SingleEntityCredentialManager; import org.keycloak.models.UserModel; import org.keycloak.models.UserModelDefaultMethods; import org.keycloak.models.utils.RoleUtils; @@ -400,6 +402,11 @@ public abstract class AbstractUserAdapterFederatedStorage extends UserModelDefau } + @Override + public SingleEntityCredentialManager credentialManager() { + return new LegacySingleUserCredentialManager(session, realm, this); + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/BackwardsCompatibilityUserStorage.java b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/BackwardsCompatibilityUserStorage.java index c27a9f5f6a..f4f8ce2d09 100644 --- a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/BackwardsCompatibilityUserStorage.java +++ b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/BackwardsCompatibilityUserStorage.java @@ -102,11 +102,6 @@ public class BackwardsCompatibilityUserStorage implements UserLookupProvider, Us throw new RuntimeException("Unsupported to change username"); } } - - @Override - public SingleEntityCredentialManager credentialManager() { - return new LegacySingleUserCredentialManager(session, realm, this); - } }; } diff --git a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/PassThroughFederatedUserStorageProvider.java b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/PassThroughFederatedUserStorageProvider.java index e0c3e2c34e..9d44c4e9ec 100644 --- a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/PassThroughFederatedUserStorageProvider.java +++ b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/PassThroughFederatedUserStorageProvider.java @@ -165,11 +165,6 @@ public class PassThroughFederatedUserStorageProvider implements @Override public void setUsername(String username) { } - - @Override - public SingleEntityCredentialManager credentialManager() { - return new LegacySingleUserCredentialManager(session, realm, this); - } }; } } diff --git a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorage.java b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorage.java index 87cf3a9660..bb34b195ad 100644 --- a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorage.java +++ b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorage.java @@ -144,11 +144,6 @@ public class UserMapStorage implements UserLookupProvider.Streams, UserStoragePr public String getFederationLink() { return model.getId(); } - - @Override - public SingleEntityCredentialManager credentialManager() { - return new LegacySingleUserCredentialManager(session, realm, this); - } }; } diff --git a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserPropertyFileStorage.java b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserPropertyFileStorage.java index 5c6ec82bff..a2b5800a32 100644 --- a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserPropertyFileStorage.java +++ b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserPropertyFileStorage.java @@ -134,11 +134,6 @@ public class UserPropertyFileStorage implements UserLookupProvider.Streams, User public void setUsername(String username) { throw new RuntimeException("Unsupported"); } - - @Override - public SingleEntityCredentialManager credentialManager() { - return new LegacySingleUserCredentialManager(session, realm, this); - } }; } else { return new AbstractUserAdapter.Streams(session, realm, model) {