diff --git a/server-spi/src/main/java/org/keycloak/models/KeycloakSession.java b/server-spi/src/main/java/org/keycloak/models/KeycloakSession.java index 1ee2bb74b1..1ab564612f 100755 --- a/server-spi/src/main/java/org/keycloak/models/KeycloakSession.java +++ b/server-spi/src/main/java/org/keycloak/models/KeycloakSession.java @@ -71,7 +71,7 @@ public interface KeycloakSession { * @param clazz * @param componentId Component configuration * @throws IllegalArgumentException If the realm is not set in the context. - * @return Provider configured according to the {@link componentId}, {@code null} if it cannot be instantiated. + * @return Provider configured according to the {@param componentId}, {@code null} if it cannot be instantiated. */ T getComponentProvider(Class clazz, String componentId); @@ -83,7 +83,7 @@ public interface KeycloakSession { * @param componentId Component configuration * @param modelGetter Getter to retrieve componentModel * @throws IllegalArgumentException If the realm is not set in the context. - * @return Provider configured according to the {@link componentId}, {@code null} if it cannot be instantiated. + * @return Provider configured according to the {@param componentId}, {@code null} if it cannot be instantiated. */ T getComponentProvider(Class clazz, String componentId, Function modelGetter); @@ -209,34 +209,39 @@ public interface KeycloakSession { * * @return may be null if cache is disabled */ + @Deprecated UserCache userCache(); /** * A cached view of all users in system including users loaded by UserStorageProviders * - * @return + * @return UserProvider instance */ UserProvider users(); /** * @return ClientStorageManager instance */ + @Deprecated ClientProvider clientStorageManager(); /** * @return ClientScopeStorageManager instance * @deprecated Use {@link #clientScopes()} instead */ + @Deprecated ClientScopeProvider clientScopeStorageManager(); /** * @return RoleStorageManager instance */ + @Deprecated RoleProvider roleStorageManager(); /** * @return GroupStorageManager instance */ + @Deprecated GroupProvider groupStorageManager(); /** @@ -244,11 +249,12 @@ public interface KeycloakSession { * * @return */ + @Deprecated UserProvider userStorageManager(); /** * Service that allows you to valid and update credentials for a user - * @deprecated Use {@link UserModel#getUserCredentialManager()} instead. + * @deprecated Use {@link UserModel#credentialManager()} instead. * @return */ @Deprecated @@ -256,11 +262,11 @@ public interface KeycloakSession { /** * Keycloak specific local storage for users. No cache in front, this api talks directly to database configured for Keycloak - * - * @return */ + @Deprecated UserProvider userLocalStorage(); + @Deprecated RealmProvider realmLocalStorage(); /** @@ -268,6 +274,7 @@ public interface KeycloakSession { * * @return */ + @Deprecated ClientProvider clientLocalStorage(); /** @@ -276,6 +283,7 @@ public interface KeycloakSession { * @deprecated Use {@link #clientScopes()} instead * @return */ + @Deprecated ClientScopeProvider clientScopeLocalStorage(); /** @@ -283,6 +291,7 @@ public interface KeycloakSession { * * @return */ + @Deprecated GroupProvider groupLocalStorage(); /** @@ -290,6 +299,7 @@ public interface KeycloakSession { * * @return */ + @Deprecated RoleProvider roleLocalStorage(); /** @@ -298,6 +308,7 @@ public interface KeycloakSession { * * @return */ + @Deprecated UserFederatedStorageProvider userFederatedStorage(); /** diff --git a/services/src/main/java/org/keycloak/services/DefaultKeycloakSession.java b/services/src/main/java/org/keycloak/services/DefaultKeycloakSession.java index ea84261e97..7693394cdb 100644 --- a/services/src/main/java/org/keycloak/services/DefaultKeycloakSession.java +++ b/services/src/main/java/org/keycloak/services/DefaultKeycloakSession.java @@ -16,6 +16,8 @@ */ package org.keycloak.services; +import org.jboss.logging.Logger; +import org.keycloak.common.util.StackUtil; import org.keycloak.component.ComponentFactory; import org.keycloak.component.ComponentModel; import org.keycloak.jose.jws.DefaultTokenManager; @@ -69,6 +71,7 @@ import java.util.stream.Collectors; */ public class DefaultKeycloakSession implements KeycloakSession { + private final static Logger log = Logger.getLogger(DefaultKeycloakSession.class); private final DefaultKeycloakSessionFactory factory; private final Map providers = new HashMap<>(); private final List closable = new LinkedList<>(); @@ -167,59 +170,68 @@ public class DefaultKeycloakSession implements KeycloakSession { } @Override - @Deprecated // put deprecated on the interface + @Deprecated public UserProvider userLocalStorage() { - // TODO: if we would call users() here, we could get the cache in legacy mode instead and would then loop - return getProvider(UserProvider.class); + log.warnf("The semantics of this method have changed: Please see the migration guide on how to migrate.%s", StackUtil.getShortStackTrace()); + return users(); } @Override - @Deprecated // put deprecated on the interface (all *LocalStorage, all *Managers) + @Deprecated public RealmProvider realmLocalStorage() { return realms(); } @Override + @Deprecated public ClientProvider clientLocalStorage() { return clients(); } @Override + @Deprecated public ClientScopeProvider clientScopeLocalStorage() { return clientScopes(); } @Override + @Deprecated public GroupProvider groupLocalStorage() { return groups(); } @Override + @Deprecated public ClientProvider clientStorageManager() { return clients(); } @Override + @Deprecated public ClientScopeProvider clientScopeStorageManager() { return clientScopes(); } @Override + @Deprecated public RoleProvider roleLocalStorage() { return roles(); } @Override + @Deprecated public RoleProvider roleStorageManager() { return roles(); } @Override + @Deprecated public GroupProvider groupStorageManager() { return groups(); } @Override + @Deprecated public UserProvider userStorageManager() { return users(); } @@ -322,7 +334,6 @@ public class DefaultKeycloakSession implements KeycloakSession { return null; } - @SuppressWarnings("unchecked") ComponentFactory componentFactory = (ComponentFactory) providerFactory; T provider = componentFactory.create(this, componentModel); enlistForClose(provider);