Clean-up of deprecated methods and interfaces

Fixes #20877

Co-authored-by: andymunro <48995441+andymunro@users.noreply.github.com>
This commit is contained in:
Vlasta Ramik 2023-06-09 19:11:20 +02:00 committed by GitHub
parent fbfdb54745
commit ed473da22b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 119 additions and 941 deletions

View file

@ -26,47 +26,14 @@ public interface UserFederatedStorageProvider extends Provider,
UserFederatedUserCredentialStore {
...
Stream<GroupModel> getGroupsStream(RealmModel realm, String userId)
void joinGroup(RealmModel realm, String userId, GroupModel group);
void leaveGroup(RealmModel realm, String userId, GroupModel group);
Stream<String> getMembershipStream(RealmModel realm, GroupModel group, Integer firstResult, Integer max);
...
interface Streams extends UserFederatedStorageProvider,
UserAttributeFederatedStorage.Streams,
UserBrokerLinkFederatedStorage.Streams,
UserConsentFederatedStorage.Streams,
UserFederatedUserCredentialStore.Streams,
UserGroupMembershipFederatedStorage.Streams,
UserRequiredActionsFederatedStorage.Streams,
UserRoleMappingsFederatedStorage.Streams {
...
@Override
default List<String> getStoredUsers(RealmModel realm, int first, int max) {
return this.getStoredUsersStream(realm, first, max).collect(Collectors.toList());
}
@Override
Stream<String> getStoredUsersStream(RealmModel realm, Integer first, Integer max);
...
}
}
----
The `UserFederatedStorageProvider` instance is available on the `KeycloakSession.userFederatedStorage()` method.
The `UserFederatedStorageProvider` instance is available on the `UserStorageUtil.userFederatedStorage(KeycloakSession)` method.
It has all different kinds of methods for storing attributes, group and role mappings, different credential types,
and required actions. If your external store's datamodel cannot support the full {project_name} feature
set, then this service can fill in the gaps.
Also, the `UserFederatedStorageProvider.Streams` interface exists. It makes all collection-based methods in `UserFederatedStorageProvider`
default by providing implementations that delegate to the stream-based variants instead of the other way around.
It allows for implementations to focus on the stream-based approach for processing sets of data and benefit
from the potential memory and performance optimizations of that approach. See <<_stream_based_interfaces,Stream-based interfaces>> for more information.
{project_name} comes with a helper class `org.keycloak.storage.adapter.AbstractUserAdapterFederatedStorage`
that will delegate every single `UserModel` method except get/set of username to user federated storage. Override
the methods you need to override to delegate to your external storage representations. It is strongly

View file

@ -335,3 +335,17 @@ You need to add an empty `META-INF/beans.xml` to the JAR file where your custom
at runtime.
You should also make sure your JAX-RS methods are declaring the expected media types for input and output by marking them with the `@Consumes` and `@Produces` annotations, respectively.
= Deprecated methods from data providers and models
In earlier versions of Keycloak, provider and model interfaces underwent a cleanup process that involved deprecating certain methods.
In this release the methods were removed and some additional methods were deprecated. The Javadoc for these methods from Keycloak 21 included information about
their corresponding replacements.
* `RealmModel#searchForGroupByNameStream(String, Integer, Integer)` was removed.
* `UserProvider#getUsersStream(RealmModel, boolean)` was removed.
* `UserSessionPersisterProvider#loadUserSessions(int, int, boolean, int, String)` was removed.
* Interfaces added for Streamification work were removed. Such as `RoleMapperModel.Streams` and similar.
* `Streams` interfaces in federated storage provider classes were deprecated.
* `KeycloakModelUtils#getClientScopeMappings` was removed.
* Deprecated methods from `KeycloakSession` were removed.

View file

@ -1446,12 +1446,6 @@ public class RealmAdapter implements CachedRealmModel {
return cacheSession.getTopLevelGroupsStream(this, first, max);
}
@Override
@Deprecated
public Stream<GroupModel> searchForGroupByNameStream(String search, Integer first, Integer max) {
return cacheSession.searchForGroupByNameStream( this, search, false, first, max);
}
@Override
public boolean removeGroup(GroupModel group) {
return cacheSession.removeGroup(this, group);

View file

@ -1923,12 +1923,6 @@ public class RealmAdapter implements LegacyRealmModel, JpaModel<RealmEntity> {
return session.groups().getTopLevelGroupsStream(this, first, max);
}
@Override
@Deprecated
public Stream<GroupModel> searchForGroupByNameStream(String search, Integer first, Integer max) {
return session.groups().searchForGroupByNameStream(this, search, false, first, max);
}
@Override
public boolean removeGroup(GroupModel group) {
return session.groups().removeGroup(this, group);

View file

@ -71,7 +71,7 @@ import static org.keycloak.utils.StreamsUtil.closing;
* @version $Revision: 1 $
*/
public class JpaUserFederatedStorageProvider implements
UserFederatedStorageProvider.Streams,
UserFederatedStorageProvider,
UserCredentialStore {
protected static final Logger logger = Logger.getLogger(JpaUserFederatedStorageProvider.class);

View file

@ -25,9 +25,7 @@ import org.keycloak.models.UserSessionModel;
import org.keycloak.provider.Provider;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -88,15 +86,6 @@ public interface UserSessionPersisterProvider extends Provider {
*/
Stream<UserSessionModel> loadUserSessionsStream(RealmModel realm, ClientModel client, boolean offline, Integer firstResult, Integer maxResults);
/**
* Called during startup. For each userSession, it loads also clientSessions
* @deprecated Use {@link #loadUserSessionsStream(Integer, Integer, boolean, String) loadUserSessionsStream} instead.
*/
@Deprecated
default List<UserSessionModel> loadUserSessions(int firstResult, int maxResults, boolean offline, int lastCreatedOn, String lastUserSessionId) {
return loadUserSessionsStream(firstResult, maxResults, offline, lastUserSessionId).collect(Collectors.toList());
}
/**
* Called during startup. For each userSession, it loads also clientSessions.
* @param firstResult {@code Integer} Index of the first desired user session. Ignored if negative or {@code null}.

View file

@ -41,7 +41,7 @@ import java.util.stream.Stream;
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class InMemoryUserAdapter extends UserModelDefaultMethods.Streams {
public class InMemoryUserAdapter extends UserModelDefaultMethods {
private Long createdTimestamp = Time.currentTimeMillis();
private boolean emailVerified;
private boolean enabled;

View file

@ -46,9 +46,4 @@ public class LegacySessionSupportProviderImpl implements LegacySessionSupportPro
return new UserCredentialStoreManager(session);
}
@Override
public UserCache userCache() {
return session.getProvider(UserCache.class);
}
}

View file

@ -0,0 +1,18 @@
#
# Copyright 2023 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.keycloak.services.legacysessionsupport.LegacySessionSupportSpi

View file

@ -30,6 +30,4 @@ public interface LegacySessionSupportProvider extends Provider {
@Deprecated
UserCredentialManager userCredentialManager();
@Deprecated
UserProvider userCache();
}

View file

@ -21,8 +21,6 @@ import org.keycloak.credential.CredentialModel;
import org.keycloak.credential.UserCredentialStore;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**

View file

@ -17,8 +17,6 @@
package org.keycloak.models;
import java.util.stream.Stream;
/**
* @author <a href="mailto:external.Martin.Idel@bosch.io">Martin Idel</a>
* @version $Revision: 1 $
@ -60,13 +58,4 @@ public abstract class UserModelDefaultMethods implements UserModel {
public String toString() {
return getClass().getName() + "@" + getId();
}
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
public abstract static class Streams extends UserModelDefaultMethods implements UserModel {
}
}

View file

@ -17,7 +17,6 @@
package org.keycloak.models.cache;
import org.keycloak.models.UserModel;
import org.keycloak.models.UserProvider;
import java.util.concurrent.ConcurrentMap;
@ -57,12 +56,4 @@ public interface CachedUserModel extends UserModel {
* @return
*/
ConcurrentMap getCachedWith();
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends CachedUserModel, UserModel.Streams {
}
}

View file

@ -47,12 +47,4 @@ public interface UserCache extends UserProvider {
*
*/
void clear();
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserCache, UserProvider.Streams {
}
}

View file

@ -33,7 +33,6 @@ import org.keycloak.storage.UserStorageUtil;
import org.keycloak.storage.federated.UserFederatedStorageProvider;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -73,16 +72,9 @@ public abstract class AbstractUserAdapterFederatedStorage extends UserModelDefau
return UserStorageUtil.userFederatedStorage(session);
}
/**
* @deprecated Use {@link #getRequiredActionsStream()} instead
*/
public Set<String> getRequiredActions() {
return getFederatedStorage().getRequiredActions(realm, this.getId());
}
@Override
public Stream<String> getRequiredActionsStream() {
return getRequiredActions().stream();
return getFederatedStorage().getRequiredActionsStream(realm, this.getId());
}
@Override
@ -94,7 +86,6 @@ public abstract class AbstractUserAdapterFederatedStorage extends UserModelDefau
@Override
public void removeRequiredAction(String action) {
getFederatedStorage().removeRequiredAction(realm, this.getId(), action);
}
@Override
@ -133,20 +124,12 @@ public abstract class AbstractUserAdapterFederatedStorage extends UserModelDefau
* Also calls getGroupsInternal() method
* to pull group membership from provider. Implementors can override that method
*
*
* @return
* @deprecated Use {@link #getGroupsStream()} instead
*/
public Set<GroupModel> getGroups() {
Set<GroupModel> set = new HashSet<>(getFederatedStorage().getGroups(realm, this.getId()));
if (appendDefaultGroups()) set.addAll(realm.getDefaultGroupsStream().collect(Collectors.toSet()));
set.addAll(getGroupsInternal());
return set;
}
@Override
public Stream<GroupModel> getGroupsStream() {
return getGroups().stream();
Stream<GroupModel> groups = getFederatedStorage().getGroupsStream(realm, this.getId());
if (appendDefaultGroups()) groups = Stream.concat(groups, realm.getDefaultGroupsStream());
return Stream.concat(groups, getGroupsInternal().stream());
}
@Override
@ -163,56 +146,38 @@ public abstract class AbstractUserAdapterFederatedStorage extends UserModelDefau
@Override
public boolean isMemberOf(GroupModel group) {
return RoleUtils.isMember(getGroups().stream(), group);
return RoleUtils.isMember(getGroupsStream(), group);
}
/**
* Gets role mappings from federated storage and automatically appends default roles.
* Also calls getRoleMappingsInternal() method
* to pull role mappings from provider. Implementors can override that method
*
*
* @return
*
* @deprecated Use {@link #getRealmRoleMappingsStream()} instead
*/
public Set<RoleModel> getRealmRoleMappings() {
return this.getRoleMappings().stream().filter(RoleUtils::isRealmRole).collect(Collectors.toSet());
}
@Override
public Stream<RoleModel> getRealmRoleMappingsStream() {
return getRealmRoleMappings().stream();
return this.getRoleMappingsStream().filter(RoleUtils::isRealmRole);
}
/**
* Gets role mappings from federated storage and automatically appends default roles.
* Also calls getRoleMappingsInternal() method
* to pull role mappings from provider. Implementors can override that method
*
*
* @return
* @deprecated Use {@link #getClientRoleMappingsStream(ClientModel)} instead
*/
public Set<RoleModel> getClientRoleMappings(ClientModel app) {
return getRoleMappings().stream().filter(r -> RoleUtils.isClientRole(r, app)).collect(Collectors.toSet());
}
@Override
public Stream<RoleModel> getClientRoleMappingsStream(ClientModel app) {
return getClientRoleMappings(app).stream();
return getRoleMappingsStream().filter(r -> RoleUtils.isClientRole(r, app));
}
@Override
public boolean hasRole(RoleModel role) {
return RoleUtils.hasRole(getRoleMappings().stream(), role)
|| RoleUtils.hasRoleFromGroup(getGroups().stream(), role, true);
return RoleUtils.hasRole(getRoleMappingsStream(), role)
|| RoleUtils.hasRoleFromGroup(getGroupsStream(), role, true);
}
@Override
public void grantRole(RoleModel role) {
getFederatedStorage().grantRole(realm, this.getId(), role);
}
/**
@ -234,25 +199,26 @@ public abstract class AbstractUserAdapterFederatedStorage extends UserModelDefau
* Gets role mappings from federated storage and automatically appends default roles.
* Also calls getRoleMappingsInternal() method
* to pull role mappings from provider. Implementors can override that method
*
* @return
*
* @deprecated Use {@link #getRoleMappingsStream()} instead
*/
public Set<RoleModel> getRoleMappings() {
Set<RoleModel> set = new HashSet<>(getFederatedRoleMappings());
if (appendDefaultRolesToRoleMappings()) set.addAll(realm.getDefaultRole().getCompositesStream().collect(Collectors.toSet()));
set.addAll(getRoleMappingsInternal());
return set;
}
@Override
public Stream<RoleModel> getRoleMappingsStream() {
return getRoleMappings().stream();
Stream<RoleModel> roleMappings = getFederatedRoleMappingsStream();
if (appendDefaultRolesToRoleMappings()) {
roleMappings = Stream.concat(roleMappings, realm.getDefaultRole().getCompositesStream());
}
return Stream.concat(roleMappings, getRoleMappingsInternal().stream());
}
/**
* @deprecated Use {@link #getFederatedRoleMappingsStream()} instead
*/
@Deprecated
protected Set<RoleModel> getFederatedRoleMappings() {
return getFederatedStorage().getRoleMappings(realm, this.getId());
return getFederatedRoleMappingsStream().collect(Collectors.toSet());
}
protected Stream<RoleModel> getFederatedRoleMappingsStream() {
return getFederatedStorage().getRoleMappingsStream(realm, this.getId());
}
@Override
@ -363,7 +329,7 @@ public abstract class AbstractUserAdapterFederatedStorage extends UserModelDefau
@Override
public void setAttribute(String name, List<String> values) {
if (UserModel.USERNAME.equals(name)) {
setUsername((values != null && values.size() > 0) ? values.get(0) : null);
setUsername((values != null && !values.isEmpty()) ? values.get(0) : null);
} else {
getFederatedStorage().setAttribute(realm, this.getId(), mapAttribute(name), values);
}
@ -393,20 +359,13 @@ public abstract class AbstractUserAdapterFederatedStorage extends UserModelDefau
return attributes;
}
/**
* @deprecated Use {@link #getAttributeStream(String)} instead
*/
public List<String> getAttribute(String name) {
if (UserModel.USERNAME.equals(name)) {
return Collections.singletonList(getUsername());
}
List<String> result = getFederatedStorage().getAttributes(realm, this.getId()).get(mapAttribute(name));
return (result == null) ? Collections.emptyList() : result;
}
@Override
public Stream<String> getAttributeStream(String name) {
return getAttribute(name).stream();
if (UserModel.USERNAME.equals(name)) {
return Stream.of(getUsername());
}
List<String> result = getFederatedStorage().getAttributes(realm, this.getId()).get(mapAttribute(name));
return (result == null) ? Stream.empty() : result.stream();
}
protected String mapAttribute(String attributeName) {
@ -459,101 +418,14 @@ public abstract class AbstractUserAdapterFederatedStorage extends UserModelDefau
}
/**
* The {@link Streams} interface makes all collection-based methods in {@link AbstractUserAdapterFederatedStorage} default by providing
* implementations that delegate to the {@link Stream}-based variants instead of the other way around.
* <p/>
* It allows for implementations to focus on the {@link Stream}-based approach for processing sets of data and benefit
* from the potential memory and performance optimizations of that approach.
* @deprecated This interface is no longer necessary; collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
public abstract static class Streams extends AbstractUserAdapterFederatedStorage implements UserModel {
public Streams(final KeycloakSession session, final RealmModel realm, final ComponentModel storageProviderModel) {
super(session, realm, storageProviderModel);
}
// user-related methods.
@Override
public Set<String> getRequiredActions() {
return this.getRequiredActionsStream().collect(Collectors.toSet());
}
@Override
public Stream<String> getRequiredActionsStream() {
return super.getFederatedStorage().getRequiredActionsStream(super.realm, super.getId());
}
@Override
public List<String> getAttribute(String name) {
return this.getAttributeStream(name).collect(Collectors.toList());
}
@Override
public Stream<String> getAttributeStream(String name) {
if (UserModel.USERNAME.equals(name)) {
return Stream.of(getUsername());
}
List<String> result = super.getFederatedStorage().getAttributes(realm, this.getId()).get(super.mapAttribute(name));
return (result == null) ? Stream.empty() : result.stream();
}
// group-related methods.
@Override
public Set<GroupModel> getGroups() {
return this.getGroupsStream().collect(Collectors.toSet());
}
@Override
public Stream<GroupModel> getGroupsStream() {
Stream<GroupModel> groups = getFederatedStorage().getGroupsStream(realm, this.getId());
if (appendDefaultGroups()) groups = Stream.concat(groups, realm.getDefaultGroupsStream());
return Stream.concat(groups, getGroupsInternal().stream());
}
@Override
public boolean isMemberOf(GroupModel group) {
return RoleUtils.isMember(this.getGroupsStream(), group);
}
// role-related methods.
@Override
public Set<RoleModel> getRealmRoleMappings() {
return this.getRealmRoleMappingsStream().collect(Collectors.toSet());
}
@Override
public Stream<RoleModel> getRealmRoleMappingsStream() {
return getRoleMappingsStream().filter(RoleUtils::isRealmRole);
}
@Override
public Set<RoleModel> getClientRoleMappings(ClientModel app) {
return this.getClientRoleMappingsStream(app).collect(Collectors.toSet());
}
@Override
public Stream<RoleModel> getClientRoleMappingsStream(ClientModel app) {
return getRoleMappingsStream().filter(r -> RoleUtils.isClientRole(r, app));
}
@Override
public Set<RoleModel> getRoleMappings() {
return this.getRoleMappingsStream().collect(Collectors.toSet());
}
@Override
public Stream<RoleModel> getRoleMappingsStream() {
Stream<RoleModel> roleMappings = getFederatedRoleMappings().stream();
if (appendDefaultRolesToRoleMappings()) roleMappings = Stream.concat(roleMappings, realm.getDefaultRole().getCompositesStream());
return Stream.concat(roleMappings, getRoleMappingsInternal().stream());
}
@Override
public boolean hasRole(RoleModel role) {
return RoleUtils.hasRole(this.getRoleMappingsStream(), role)
|| RoleUtils.hasRoleFromGroup(this.getGroupsStream(), role, true);
}
}
}

View file

@ -20,7 +20,6 @@ import org.keycloak.common.util.MultivaluedHashMap;
import org.keycloak.models.RealmModel;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -33,12 +32,6 @@ public interface UserAttributeFederatedStorage {
void removeAttribute(RealmModel realm, String userId, String name);
MultivaluedHashMap<String, String> getAttributes(RealmModel realm, String userId);
/**
* @deprecated Use {@link #getUsersByUserAttributeStream(RealmModel, String, String) getUsersByUserAttributeStream} instead.
*/
@Deprecated
List<String> getUsersByUserAttribute(RealmModel realm, String name, String value);
/**
* Searches for federated users that have an attribute with the specified {@code name} and {@code value}.
*
@ -47,27 +40,13 @@ public interface UserAttributeFederatedStorage {
* @param value the attribute value.
* @return a non-null {@link Stream} of users that match the search criteria.
*/
default Stream<String> getUsersByUserAttributeStream(RealmModel realm, String name, String value) {
List<String> users = this.getUsersByUserAttribute(realm, name, value);
return users != null ? users.stream() : Stream.empty();
}
Stream<String> getUsersByUserAttributeStream(RealmModel realm, String name, String value);
/**
* The {@link Streams} interface makes all collection-based methods in {@link UserAttributeFederatedStorage}
* default by providing implementations that delegate to the {@link Stream}-based variants instead of the other way
* around.
* <p/>
* It allows for implementations to focus on the {@link Stream}-based approach for processing sets of data and benefit
* from the potential memory and performance optimizations of that approach.
* @deprecated This interface is no longer necessary; collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserAttributeFederatedStorage {
@Override
default List<String> getUsersByUserAttribute(RealmModel realm, String name, String value) {
return this.getUsersByUserAttributeStream(realm, name, value).collect(Collectors.toList());
}
@Override
Stream<String> getUsersByUserAttributeStream(RealmModel realm, String name, String value);
}
}

View file

@ -20,8 +20,6 @@ import org.keycloak.models.FederatedIdentityModel;
import org.keycloak.models.IdentityProviderModel;
import org.keycloak.models.RealmModel;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -35,12 +33,6 @@ public interface UserBrokerLinkFederatedStorage {
void preRemove(RealmModel realm, IdentityProviderModel provider);
void updateFederatedIdentity(RealmModel realm, String userId, FederatedIdentityModel federatedIdentityModel);
/**
* @deprecated Use {@link #getFederatedIdentitiesStream(String, RealmModel) getFederatedIdentitiesStream} instead.
*/
@Deprecated
Set<FederatedIdentityModel> getFederatedIdentities(String userId, RealmModel realm);
/**
* Obtains the identities of the federated user identified by {@code userId}.
*
@ -48,28 +40,15 @@ public interface UserBrokerLinkFederatedStorage {
* @param realm a reference to the realm.
* @return a non-null {@link Stream} of federated identities associated with the user.
*/
default Stream<FederatedIdentityModel> getFederatedIdentitiesStream(String userId, RealmModel realm) {
Set<FederatedIdentityModel> value = this.getFederatedIdentities(userId, realm);
return value != null ? value.stream() : Stream.empty();
}
Stream<FederatedIdentityModel> getFederatedIdentitiesStream(String userId, RealmModel realm);
FederatedIdentityModel getFederatedIdentity(String userId, String socialProvider, RealmModel realm);
/**
* The {@link Streams} interface makes all collection-based methods in {@link UserBrokerLinkFederatedStorage}
* default by providing implementations that delegate to the {@link Stream}-based variants instead of the other way
* around.
* <p/>
* It allows for implementations to focus on the {@link Stream}-based approach for processing sets of data and benefit
* from the potential memory and performance optimizations of that approach.
* @deprecated This interface is no longer necessary; collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserBrokerLinkFederatedStorage {
@Override
default Set<FederatedIdentityModel> getFederatedIdentities(String userId, RealmModel realm) {
return this.getFederatedIdentitiesStream(userId, realm).collect(Collectors.toSet());
}
@Override
Stream<FederatedIdentityModel> getFederatedIdentitiesStream(String userId, RealmModel realm);
}
}

View file

@ -19,8 +19,6 @@ package org.keycloak.storage.federated;
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserConsentModel;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -31,12 +29,6 @@ public interface UserConsentFederatedStorage {
void addConsent(RealmModel realm, String userId, UserConsentModel consent);
UserConsentModel getConsentByClient(RealmModel realm, String userId, String clientInternalId);
/**
* @deprecated Use {@link #getConsentsStream(RealmModel, String) getConsentsStream} instead.
*/
@Deprecated
List<UserConsentModel> getConsents(RealmModel realm, String userId);
/**
* Obtains the consents associated with the federated user identified by {@code userId}.
*
@ -44,29 +36,16 @@ public interface UserConsentFederatedStorage {
* @param userId the user identifier.
* @return a non-null {@link Stream} of consents associated with the user.
*/
default Stream<UserConsentModel> getConsentsStream(RealmModel realm, String userId) {
List<UserConsentModel> value = this.getConsents(realm, userId);
return value != null ? value.stream() : Stream.empty();
}
Stream<UserConsentModel> getConsentsStream(RealmModel realm, String userId);
void updateConsent(RealmModel realm, String userId, UserConsentModel consent);
boolean revokeConsentForClient(RealmModel realm, String userId, String clientInternalId);
/**
* The {@link Streams} interface makes all collection-based methods in {@link UserConsentFederatedStorage}
* default by providing implementations that delegate to the {@link Stream}-based variants instead of the other way
* around.
* <p/>
* It allows for implementations to focus on the {@link Stream}-based approach for processing sets of data and benefit
* from the potential memory and performance optimizations of that approach.
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserConsentFederatedStorage {
@Override
default List<UserConsentModel> getConsents(RealmModel realm, String userId) {
return this.getConsentsStream(realm, userId).collect(Collectors.toList());
}
@Override
Stream<UserConsentModel> getConsentsStream(RealmModel realm, String userId);
}
}

View file

@ -27,8 +27,6 @@ import org.keycloak.models.RoleModel;
import org.keycloak.models.UserModel;
import org.keycloak.provider.Provider;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -45,12 +43,6 @@ public interface UserFederatedStorageProvider extends Provider,
UserRoleMappingsFederatedStorage,
UserFederatedUserCredentialStore {
/**
* @deprecated Use {@link #getStoredUsersStream(RealmModel, Integer, Integer) getStoredUsersStream} instead.
*/
@Deprecated
List<String> getStoredUsers(RealmModel realm, int first, int max);
/**
* Obtains the ids of all federated users in the realm.
*
@ -59,10 +51,7 @@ public interface UserFederatedStorageProvider extends Provider,
* @param max maximum number of results to return. Ignored if negative or {@code null}.
* @return a non-null {@link Stream} of federated user ids.
*/
default Stream<String> getStoredUsersStream(RealmModel realm, Integer first, Integer max) {
List<String> value = this.getStoredUsers(realm, first, max);
return value != null ? value.stream() : Stream.empty();
}
Stream<String> getStoredUsersStream(RealmModel realm, Integer first, Integer max);
int getStoredUsersCount(RealmModel realm);
@ -83,13 +72,10 @@ public interface UserFederatedStorageProvider extends Provider,
void preRemove(RealmModel realm, ComponentModel model);
/**
* The {@link UserFederatedStorageProvider.Streams} interface makes all collection-based methods in {@link UserFederatedStorageProvider}
* default by providing implementations that delegate to the {@link Stream}-based variants instead of the other way
* around.
* <p/>
* It allows for implementations to focus on the {@link Stream}-based approach for processing sets of data and benefit
* from the potential memory and performance optimizations of that approach.
* @deprecated This interface is no longer necessary; collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserFederatedStorageProvider,
UserAttributeFederatedStorage.Streams,
UserBrokerLinkFederatedStorage.Streams,
@ -98,13 +84,5 @@ public interface UserFederatedStorageProvider extends Provider,
UserGroupMembershipFederatedStorage.Streams,
UserRequiredActionsFederatedStorage.Streams,
UserRoleMappingsFederatedStorage.Streams {
@Override
default List<String> getStoredUsers(RealmModel realm, int first, int max) {
return this.getStoredUsersStream(realm, first, max).collect(Collectors.toList());
}
@Override
Stream<String> getStoredUsersStream(RealmModel realm, Integer first, Integer max);
}
}

View file

@ -20,8 +20,6 @@ import org.keycloak.credential.CredentialModel;
import org.keycloak.models.RealmModel;
import org.keycloak.provider.Provider;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -34,12 +32,6 @@ public interface UserFederatedUserCredentialStore extends Provider {
boolean removeStoredCredential(RealmModel realm, String userId, String id);
CredentialModel getStoredCredentialById(RealmModel realm, String userId, String id);
/**
* @deprecated Use {@link #getStoredCredentialsStream(RealmModel, String) getStoredCredentialsStream} instead.
*/
@Deprecated
List<CredentialModel> getStoredCredentials(RealmModel realm, String userId);
/**
* Obtains the credentials associated with the federated user identified by {@code userId}.
*
@ -47,16 +39,7 @@ public interface UserFederatedUserCredentialStore extends Provider {
* @param userId the user identifier.
* @return a non-null {@link Stream} of credentials.
*/
default Stream<CredentialModel> getStoredCredentialsStream(RealmModel realm, String userId) {
List<CredentialModel> value = this.getStoredCredentials(realm, userId);
return value != null ? value.stream() : Stream.empty();
}
/**
* @deprecated Use {@link #getStoredCredentialsByTypeStream(RealmModel, String, String) getStoredCredentialsByTypeStream} instead.
*/
@Deprecated
List<CredentialModel> getStoredCredentialsByType(RealmModel realm, String userId, String type);
Stream<CredentialModel> getStoredCredentialsStream(RealmModel realm, String userId);
/**
* Obtains the credentials of type {@code type} that are associated with the federated user identified by {@code userId}.
@ -66,36 +49,15 @@ public interface UserFederatedUserCredentialStore extends Provider {
* @param type the credential type.
* @return a non-null {@link Stream} of credentials.
*/
default Stream<CredentialModel> getStoredCredentialsByTypeStream(RealmModel realm, String userId, String type) {
List<CredentialModel> value = this.getStoredCredentialsByType(realm, userId, type);
return value != null ? value.stream() : Stream.empty();
}
Stream<CredentialModel> getStoredCredentialsByTypeStream(RealmModel realm, String userId, String type);
CredentialModel getStoredCredentialByNameAndType(RealmModel realm, String userId, String name, String type);
/**
* The {@link Streams} interface makes all collection-based methods in {@link UserFederatedUserCredentialStore}
* default by providing implementations that delegate to the {@link Stream}-based variants instead of the other way
* around.
* <p/>
* It allows for implementations to focus on the {@link Stream}-based approach for processing sets of data and benefit
* from the potential memory and performance optimizations of that approach.
* @deprecated This interface is no longer necessary; collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserFederatedUserCredentialStore {
@Override
default List<CredentialModel> getStoredCredentials(RealmModel realm, String userId) {
return this.getStoredCredentialsStream(realm, userId).collect(Collectors.toList());
}
@Override
Stream<CredentialModel> getStoredCredentialsStream(RealmModel realm, String userId);
@Override
default List<CredentialModel> getStoredCredentialsByType(RealmModel realm, String userId, String type) {
return this.getStoredCredentialsByTypeStream(realm, userId, type).collect(Collectors.toList());
}
@Override
Stream<CredentialModel> getStoredCredentialsByTypeStream(RealmModel realm, String userId, String type);
}
}

View file

@ -19,9 +19,6 @@ package org.keycloak.storage.federated;
import org.keycloak.models.GroupModel;
import org.keycloak.models.RealmModel;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -30,12 +27,6 @@ import java.util.stream.Stream;
*/
public interface UserGroupMembershipFederatedStorage {
/**
* @deprecated Use {@link #getGroupsStream(RealmModel, String) getGroupsStream} instead.
*/
@Deprecated
Set<GroupModel> getGroups(RealmModel realm, String userId);
/**
* Obtains the groups associated with the federated user.
*
@ -43,20 +34,11 @@ public interface UserGroupMembershipFederatedStorage {
* @param userId the user identifier.
* @return a non-null {@code Stream} of groups.
*/
default Stream<GroupModel> getGroupsStream(RealmModel realm, String userId) {
Set<GroupModel> value = this.getGroups(realm, userId);
return value != null ? value.stream() : Stream.empty();
}
Stream<GroupModel> getGroupsStream(RealmModel realm, String userId);
void joinGroup(RealmModel realm, String userId, GroupModel group);
void leaveGroup(RealmModel realm, String userId, GroupModel group);
/**
* @deprecated Use {@link #getMembershipStream(RealmModel, GroupModel, Integer, Integer) getMembershipStream} instead.
*/
@Deprecated
List<String> getMembership(RealmModel realm, GroupModel group, int firstResult, int max);
/**
* Obtains the federated users that are members of the given {@code group} in the specified {@code realm}.
*
@ -66,34 +48,13 @@ public interface UserGroupMembershipFederatedStorage {
* @param max maximum number of results to return. Ignored if negative or {@code null}.
* @return a non-null {@code Stream} of federated user ids that are members of the group in the realm.
*/
default Stream<String> getMembershipStream(RealmModel realm, GroupModel group, Integer firstResult, Integer max) {
List<String> value = this.getMembership(realm, group, firstResult, max);
return value != null ? value.stream() : Stream.empty();
}
Stream<String> getMembershipStream(RealmModel realm, GroupModel group, Integer firstResult, Integer max);
/**
* The {@link Streams} interface makes all collection-based methods in {@link UserGroupMembershipFederatedStorage}
* default by providing implementations that delegate to the {@link Stream}-based variants instead of the other way
* around.
* <p/>
* It allows for implementations to focus on the {@link Stream}-based approach for processing sets of data and benefit
* from the potential memory and performance optimizations of that approach.
* @deprecated This interface is no longer necessary; collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserGroupMembershipFederatedStorage {
@Override
default Set<GroupModel> getGroups(RealmModel realm, String userId) {
return getGroupsStream(realm, userId).collect(Collectors.toSet());
}
@Override
Stream<GroupModel> getGroupsStream(RealmModel realm, String userId);
@Override
default List<String> getMembership(RealmModel realm, GroupModel group, int firstResult, int max) {
return this.getMembershipStream(realm, group, firstResult, max).collect(Collectors.toList());
}
@Override
Stream<String> getMembershipStream(RealmModel realm, GroupModel group, Integer firstResult, Integer max);
}
}

View file

@ -18,8 +18,6 @@ package org.keycloak.storage.federated;
import org.keycloak.models.RealmModel;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -28,12 +26,6 @@ import java.util.stream.Stream;
*/
public interface UserRequiredActionsFederatedStorage {
/**
* @deprecated Use {@link #getRequiredActionsStream(RealmModel, String) getRequiredActionsStream} instead.
*/
@Deprecated
Set<String> getRequiredActions(RealmModel realm, String userId);
/**
* Obtains the names of required actions associated with the federated user identified by {@code userId}.
*
@ -41,29 +33,16 @@ public interface UserRequiredActionsFederatedStorage {
* @param userId the user identifier.
* @return a non-null {@link Stream} of required action names.
*/
default Stream<String> getRequiredActionsStream(RealmModel realm, String userId) {
Set<String> value = this.getRequiredActions(realm, userId);
return value != null ? value.stream() : Stream.empty();
}
Stream<String> getRequiredActionsStream(RealmModel realm, String userId);
void addRequiredAction(RealmModel realm, String userId, String action);
void removeRequiredAction(RealmModel realm, String userId, String action);
/**
* The {@link Streams} interface makes all collection-based methods in {@link UserRequiredActionsFederatedStorage}
* default by providing implementations that delegate to the {@link Stream}-based variants instead of the other way
* around.
* <p/>
* It allows for implementations to focus on the {@link Stream}-based approach for processing sets of data and benefit
* from the potential memory and performance optimizations of that approach.
* @deprecated This interface is no longer necessary; collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserRequiredActionsFederatedStorage {
@Override
default Set<String> getRequiredActions(RealmModel realm, String userId) {
return this.getRequiredActionsStream(realm, userId).collect(Collectors.toSet());
}
@Override
Stream<String> getRequiredActionsStream(RealmModel realm, String userId);
}
}

View file

@ -19,8 +19,6 @@ package org.keycloak.storage.federated;
import org.keycloak.models.RealmModel;
import org.keycloak.models.RoleModel;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -29,12 +27,6 @@ import java.util.stream.Stream;
*/
public interface UserRoleMappingsFederatedStorage {
/**
* @deprecated Use {@link #getRoleMappingsStream(RealmModel, String) getRoleMappingsStream} instead.
*/
@Deprecated
Set<RoleModel> getRoleMappings(RealmModel realm,String userId);
void grantRole(RealmModel realm, String userId, RoleModel role);
/**
@ -44,28 +36,15 @@ public interface UserRoleMappingsFederatedStorage {
* @param userId the user identifier.
* @return a non-null {@code Stream} of roles.
*/
default Stream<RoleModel> getRoleMappingsStream(RealmModel realm, String userId) {
Set<RoleModel> value = this.getRoleMappings(realm, userId);
return value != null ? value.stream() : Stream.empty();
}
Stream<RoleModel> getRoleMappingsStream(RealmModel realm, String userId);
void deleteRoleMapping(RealmModel realm, String userId, RoleModel role);
/**
* The {@link Streams} interface makes all collection-based methods in {@link UserRoleMappingsFederatedStorage}
* default by providing implementations that delegate to the {@link Stream}-based variants instead of the other way
* around.
* <p/>
* It allows for implementations to focus on the {@link Stream}-based approach for processing sets of data and benefit
* from the potential memory and performance optimizations of that approach.
* @deprecated This interface is no longer necessary; collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserRoleMappingsFederatedStorage {
@Override
default Set<RoleModel> getRoleMappings(RealmModel realm, String userId) {
return getRoleMappingsStream(realm, userId).collect(Collectors.toSet());
}
@Override
Stream<RoleModel> getRoleMappingsStream(RealmModel realm, String userId);
}
}

View file

@ -39,7 +39,6 @@ import org.keycloak.models.RoleSpi;
import org.keycloak.models.SingleUseObjectProvider;
import org.keycloak.models.ThemeManager;
import org.keycloak.models.TokenManager;
import org.keycloak.models.UserCredentialManager;
import org.keycloak.models.UserLoginFailureProvider;
import org.keycloak.models.UserProvider;
import org.keycloak.models.UserSessionProvider;
@ -275,89 +274,11 @@ public class ImportKeycloakSession implements KeycloakSession {
session.close();
}
@Override
@Deprecated
public UserProvider userCache() {
throw new ModelException("not supported");
}
@Override
public UserProvider users() {
return userProvider;
}
@Override
@Deprecated
public ClientProvider clientStorageManager() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public ClientScopeProvider clientScopeStorageManager() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public RoleProvider roleStorageManager() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public GroupProvider groupStorageManager() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public UserProvider userStorageManager() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public UserCredentialManager userCredentialManager() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public UserProvider userLocalStorage() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public RealmProvider realmLocalStorage() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public ClientProvider clientLocalStorage() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public ClientScopeProvider clientScopeLocalStorage() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public GroupProvider groupLocalStorage() {
throw new ModelException("not supported");
}
@Override
@Deprecated
public RoleProvider roleLocalStorage() {
throw new ModelException("not supported");
}
@Override
public KeyManager keys() {
throw new ModelException("not supported");

View file

@ -1445,12 +1445,6 @@ public class MapRealmAdapter extends AbstractRealmModel<MapRealmEntity> implemen
return session.groups().getTopLevelGroupsStream(this, first, max);
}
@Override
@Deprecated
public Stream<GroupModel> searchForGroupByNameStream(String search, Integer first, Integer max) {
return session.groups().searchForGroupByNameStream(this, search, false, first, max);
}
@Override
public boolean removeGroup(GroupModel group) {
return session.groups().removeGroup(this, group);

View file

@ -763,17 +763,6 @@ public final class KeycloakModelUtils {
return normalized;
}
/**
* @param client {@link ClientModel}
* @param container {@link ScopeContainerModel}
* @return
* @deprecated Use {@link #getClientScopeMappingsStream(ClientModel, ScopeContainerModel)} getClientScopeMappingsStream} instead.
*/
@Deprecated
public static Set<RoleModel> getClientScopeMappings(ClientModel client, ScopeContainerModel container) {
return getClientScopeMappingsStream(client, container).collect(Collectors.toSet());
}
public static Stream<RoleModel> getClientScopeMappingsStream(ClientModel client, ScopeContainerModel container) {
return container.getScopeMappingsStream()
.filter(role -> role.getContainer() instanceof ClientModel &&

View file

@ -170,12 +170,6 @@ public class ModelToRepresentation {
return groups.map(g -> toGroupHierarchy(g, full, attributes));
}
@Deprecated
public static Stream<GroupRepresentation> searchForGroupByName(RealmModel realm, boolean full, String search, Integer first, Integer max) {
return realm.searchForGroupByNameStream(search, first, max)
.map(g -> toGroupHierarchy(g, full, search));
}
public static Stream<GroupRepresentation> searchForGroupByName(KeycloakSession session, RealmModel realm, boolean full, String search, Boolean exact, Integer first, Integer max) {
return session.groups().searchForGroupByNameStream(realm, search, exact, first, max)
.map(g -> toGroupHierarchy(g, full, search, exact));

View file

@ -1653,11 +1653,6 @@ public class IdentityBrokerStateTestHelpers {
return null;
}
@Override
public Stream<GroupModel> searchForGroupByNameStream(String search, Integer first, Integer max) {
return null;
}
@Override
public boolean removeGroup(GroupModel group) {
return false;

View file

@ -19,8 +19,6 @@ package org.keycloak.credential;
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserModel;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -41,12 +39,4 @@ public interface CredentialInputUpdater {
* @return a non-null {@link Stream} of credential types.
*/
Stream<String> getDisableableCredentialTypesStream(RealmModel realm, UserModel user);
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends CredentialInputUpdater {
}
}

View file

@ -17,12 +17,9 @@
package org.keycloak.credential;
import org.keycloak.models.RealmModel;
import org.keycloak.models.SubjectCredentialManager;
import org.keycloak.models.UserModel;
import org.keycloak.provider.Provider;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -70,11 +67,4 @@ public interface UserCredentialStore extends Provider {
//list operations
boolean moveCredentialTo(RealmModel realm, UserModel user, String id, String newPreviousCredentialId);
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserCredentialStore {
}
}

View file

@ -23,8 +23,6 @@ import org.keycloak.storage.SearchableModelField;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -130,12 +128,4 @@ public interface GroupModel extends RoleMapperModel {
* @param subGroup
*/
void removeChild(GroupModel subGroup);
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends GroupModel, RoleMapperModel {
}
}

View file

@ -203,20 +203,8 @@ public interface KeycloakSession extends AutoCloseable {
SingleUseObjectProvider singleUseObjects();
void close();
/**
* The user cache
*
* @deprecated The access to the UserCache interface is no longer possible here, and this method is about to be removed.
* Adjust your code according to the Keycloak 19 Upgrading Guide.
* @return may be null if cache is disabled
*/
@Deprecated
UserProvider userCache();
/**
* A cached view of all users in system including users loaded by UserStorageProviders
*
@ -224,88 +212,6 @@ public interface KeycloakSession extends AutoCloseable {
*/
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();
/**
* Un-cached view of all users in system including users loaded by UserStorageProviders
*
* @return
*/
@Deprecated
UserProvider userStorageManager();
/**
* Service that allows you to valid and update credentials for a user
* @deprecated Use {@link UserModel#credentialManager()} instead.
* @return
*/
@Deprecated
UserCredentialManager userCredentialManager();
/**
* Keycloak specific local storage for users. No cache in front, this api talks directly to database configured for Keycloak
*/
@Deprecated
UserProvider userLocalStorage();
@Deprecated
RealmProvider realmLocalStorage();
/**
* Keycloak specific local storage for clients. No cache in front, this api talks directly to database configured for Keycloak
*
* @deprecated Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.
*/
@Deprecated
ClientProvider clientLocalStorage();
/**
* Keycloak specific local storage for client scopes. No cache in front, this api talks directly to database configured for Keycloak
*
* @deprecated Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.
*/
@Deprecated
ClientScopeProvider clientScopeLocalStorage();
/**
* Keycloak specific local storage for groups. No cache in front, this api talks directly to storage configured for Keycloak
*
* @deprecated Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.
*/
@Deprecated
GroupProvider groupLocalStorage();
/**
* Keycloak specific local storage for roles. No cache in front, this api talks directly to storage configured for Keycloak
*
* @deprecated Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.
*/
@Deprecated
RoleProvider roleLocalStorage();
/**
* Key manager
*

View file

@ -24,10 +24,8 @@ import org.keycloak.provider.Provider;
import org.keycloak.provider.ProviderEvent;
import org.keycloak.storage.SearchableModelField;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -669,17 +667,6 @@ public interface RealmModel extends RoleContainerModel {
*/
Stream<GroupModel> getTopLevelGroupsStream(Integer first, Integer max);
/**
* Searches for groups by provided name. Results that match the given filter are returned as a stream.
* @param search {@code String} Name of a group to be used as a filter.
* @param first {@code Integer} Index of the first desired group. Ignored if negative or {@code null}.
* @param max {@code Integer} Maximum number of returned groups. Ignored if negative or {@code null}.
* @return Stream of {@link GroupModel}. Never returns {@code null}.
* @deprecated Use {@link GroupProvider#searchForGroupByNameStream(RealmModel, String, Boolean, Integer, Integer)} instead.
*/
@Deprecated
Stream<GroupModel> searchForGroupByNameStream(String search, Integer first, Integer max);
boolean removeGroup(GroupModel group);
void moveGroup(GroupModel group, GroupModel toParent);

View file

@ -18,8 +18,6 @@
package org.keycloak.models;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -85,12 +83,4 @@ public interface RoleMapperModel {
* @param role Role to remove
*/
void deleteRoleMapping(RoleModel role);
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends RoleMapperModel {
}
}

View file

@ -272,12 +272,4 @@ public interface UserModel extends RoleMapperModel {
VERIFY_PROFILE,
UPDATE_EMAIL
}
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserModel, RoleMapperModel {
}
}

View file

@ -24,11 +24,6 @@ import org.keycloak.storage.user.UserLookupProvider;
import org.keycloak.storage.user.UserQueryProvider;
import org.keycloak.storage.user.UserRegistrationProvider;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@ -72,42 +67,6 @@ public interface UserProvider extends Provider,
*/
UserModel getServiceAccount(ClientModel client);
/**
* Obtains the users associated with the specified realm.
*
* @param realm a reference to the realm being used for the search.
* @param includeServiceAccounts {@code true} if service accounts should be included in the result; {@code false} otherwise.
* @return a non-null {@link Stream} of users associated withe the realm.
*
* @deprecated Use {@link UserQueryProvider#searchForUserStream(RealmModel, Map)} with
* {@link UserModel#INCLUDE_SERVICE_ACCOUNT} within params instead.
*/
@Deprecated
default Stream<UserModel> getUsersStream(RealmModel realm, boolean includeServiceAccounts) {
Map<String, String> searchAttributes = new HashMap<>(1);
searchAttributes.put(UserModel.INCLUDE_SERVICE_ACCOUNT, Boolean.toString(includeServiceAccounts));
return this.searchForUserStream(realm, searchAttributes);
}
/**
* Obtains the users associated with the specified realm.
*
* @param realm a reference to the realm being used for the search.
* @param firstResult first result to return. Ignored if negative, zero, or {@code null}.
* @param maxResults maximum number of results to return. Ignored if negative or {@code null}.
* @param includeServiceAccounts {@code true} if service accounts should be included in the result; {@code false} otherwise.
* @return a non-null {@link Stream} of users associated withe the realm.
*
* @deprecated Use {@link UserQueryProvider#searchForUserStream(RealmModel, Map, Integer, Integer)}
* with {@link UserModel#INCLUDE_SERVICE_ACCOUNT} within params
*/
@Deprecated
default Stream<UserModel> getUsersStream(RealmModel realm, Integer firstResult, Integer maxResults, boolean includeServiceAccounts) {
Map<String, String> searchAttributes = new HashMap<>(1);
searchAttributes.put(UserModel.INCLUDE_SERVICE_ACCOUNT, Boolean.toString(includeServiceAccounts));
return this.searchForUserStream(realm, searchAttributes, firstResult, maxResults);
}
/**
* Adds a new user into the storage.
* <p/>
@ -337,14 +296,4 @@ public interface UserProvider extends Provider,
* @param component the component model
*/
void preRemove(RealmModel realm, ComponentModel component);
void close();
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserProvider, UserQueryProvider, UserLookupProvider {
}
}

View file

@ -71,12 +71,4 @@ public interface UserLookupProvider {
* @throws org.keycloak.models.ModelDuplicateException when there are more users with same email
*/
UserModel getUserByEmail(RealmModel realm, String email);
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserLookupProvider {
}
}

View file

@ -23,12 +23,4 @@ package org.keycloak.storage.user;
* It's a combination of {@link UserQueryMethodsProvider} and {@link UserCountMethodsProvider}
*/
public interface UserQueryProvider extends UserQueryMethodsProvider, UserCountMethodsProvider {
/**
* @deprecated This interface is no longer necessary, collection-based methods were removed from the parent interface
* and therefore the parent interface can be used directly
*/
@Deprecated
interface Streams extends UserQueryProvider {
}
}

View file

@ -36,7 +36,6 @@ import org.keycloak.models.RoleProvider;
import org.keycloak.models.SingleUseObjectProvider;
import org.keycloak.models.ThemeManager;
import org.keycloak.models.TokenManager;
import org.keycloak.models.UserCredentialManager;
import org.keycloak.models.UserLoginFailureProvider;
import org.keycloak.models.UserProvider;
import org.keycloak.models.UserSessionProvider;
@ -46,7 +45,6 @@ import org.keycloak.provider.ProviderFactory;
import org.keycloak.provider.InvalidationHandler.InvalidableObjectType;
import org.keycloak.provider.InvalidationHandler.ObjectType;
import org.keycloak.services.clientpolicy.ClientPolicyManager;
import org.keycloak.models.LegacySessionSupportProvider;
import org.keycloak.sessions.AuthenticationSessionProvider;
import org.keycloak.storage.DatastoreProvider;
import org.keycloak.vault.DefaultVaultTranscriber;
@ -78,8 +76,6 @@ public class DefaultKeycloakSession implements KeycloakSession {
private final Map<String, Object> attributes = new HashMap<>();
private final Map<InvalidableObjectType, Set<Object>> invalidationMap = new HashMap<>();
private DatastoreProvider datastoreProvider;
@Deprecated
private UserCredentialManager userCredentialStorageManager;
private final KeycloakContext context;
private KeyManager keyManager;
private ThemeManager themeManager;
@ -107,16 +103,6 @@ public class DefaultKeycloakSession implements KeycloakSession {
return this.datastoreProvider;
}
@Override
@Deprecated
public UserProvider userCache() {
LegacySessionSupportProvider provider = this.getProvider(LegacySessionSupportProvider.class);
if (provider == null) {
throw new IllegalStateException("legacy support for userCache is not enabled");
}
return provider.userCache();
}
@Override
public void invalidate(InvalidableObjectType type, Object... ids) {
factory.invalidate(this, type, ids);
@ -172,91 +158,13 @@ public class DefaultKeycloakSession implements KeycloakSession {
return factory;
}
@Override
@Deprecated
public UserProvider userLocalStorage() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
@Deprecated
public RealmProvider realmLocalStorage() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
@Deprecated
public ClientProvider clientLocalStorage() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
@Deprecated
public ClientScopeProvider clientScopeLocalStorage() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
@Deprecated
public GroupProvider groupLocalStorage() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
@Deprecated
public ClientProvider clientStorageManager() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
@Deprecated
public ClientScopeProvider clientScopeStorageManager() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
@Deprecated
public RoleProvider roleLocalStorage() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
@Deprecated
public RoleProvider roleStorageManager() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
@Deprecated
public GroupProvider groupStorageManager() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
@Deprecated
public UserProvider userStorageManager() {
throw new IllegalStateException("Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.");
}
@Override
public UserProvider users() {
return getDatastoreProvider().users();
}
@Override
@Deprecated
public UserCredentialManager userCredentialManager() {
if (userCredentialStorageManager == null) {
LegacySessionSupportProvider provider = this.getProvider(LegacySessionSupportProvider.class);
if (provider == null) {
throw new IllegalStateException("legacy support for a UserCredentialManager is not enabled");
}
userCredentialStorageManager = provider.userCredentialManager();
}
return userCredentialStorageManager;
}
@SuppressWarnings("unchecked")
@Override
public <T extends Provider> T getProvider(Class<T> clazz) {
Integer hash = clazz.hashCode();
T provider = (T) providers.get(hash);
@ -274,6 +182,7 @@ public class DefaultKeycloakSession implements KeycloakSession {
}
@SuppressWarnings("unchecked")
@Override
public <T extends Provider> T getProvider(Class<T> clazz, String id) {
Integer hash = clazz.hashCode() + id.hashCode();
T provider = (T) providers.get(hash);

View file

@ -18,35 +18,27 @@
package org.keycloak.services.util;
import org.keycloak.models.ClientModel;
import org.keycloak.models.RoleModel;
import org.keycloak.models.ScopeContainerModel;
import org.keycloak.models.utils.KeycloakModelUtils;
import org.keycloak.models.utils.ModelToRepresentation;
import org.keycloak.representations.idm.ClientMappingsRepresentation;
import org.keycloak.representations.idm.RoleRepresentation;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class ScopeMappedUtil {
public static ClientMappingsRepresentation toClientMappingsRepresentation(ClientModel client, ScopeContainerModel scopeContainer) {
Set<RoleModel> roleMappings = KeycloakModelUtils.getClientScopeMappings(client, scopeContainer);
List<RoleRepresentation> roles = KeycloakModelUtils.getClientScopeMappingsStream(client, scopeContainer)
.map(role -> ModelToRepresentation.toBriefRepresentation(role))
.collect(Collectors.toList());
if (!roleMappings.isEmpty()) {
if (roles.isEmpty()) return null;
ClientMappingsRepresentation mappings = new ClientMappingsRepresentation();
mappings.setId(client.getId());
mappings.setClient(client.getClientId());
List<RoleRepresentation> roles = new LinkedList<>();
mappings.setMappings(roles);
for (RoleModel role : roleMappings) {
roles.add(ModelToRepresentation.toBriefRepresentation(role));
}
return mappings;
} else {
return null;
}
}
}

View file

@ -29,5 +29,4 @@ org.keycloak.protocol.oidc.grants.ciba.channel.AuthenticationChannelSpi
org.keycloak.protocol.oidc.grants.ciba.resolvers.CIBALoginUserResolverSpi
org.keycloak.protocol.oidc.rar.AuthorizationRequestParserSpi
org.keycloak.services.resources.admin.ext.AdminRealmResourceSpi
org.keycloak.services.legacysessionsupport.LegacySessionSupportSpi
org.keycloak.theme.freemarker.FreeMarkerSPI

View file

@ -1066,7 +1066,7 @@ public class UserManagedPermissionServiceTest extends AbstractResourceServerTest
Resource resource = policy.getResources().iterator().next();
assertEquals("Resource A", resource.getName());
realm.removeGroup(realm.searchForGroupByNameStream("group_remove", -1, -1).findAny().get());
realm.removeGroup(session.groups().searchForGroupByNameStream(realm, "group_remove", false, null, null).findAny().get());
filters = new HashMap<>();

View file

@ -512,7 +512,7 @@ public class LDAPSyncTest extends AbstractLDAPTest {
RealmModel appRealm = ctx.getRealm();
// Remove all users from model
UserStoragePrivateUtil.userLocalStorage(session).getUsersStream(ctx.getRealm(), true)
UserStoragePrivateUtil.userLocalStorage(session).searchForUserStream(ctx.getRealm(), Map.of())
.peek(user -> System.out.println("trying to delete user: " + user.getUsername()))
.collect(Collectors.toList())
.forEach(user -> {

View file

@ -23,8 +23,8 @@ import com.webauthn4j.data.attestation.authenticator.COSEKey;
import org.keycloak.common.util.Base64Url;
import org.keycloak.credential.CredentialModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.UserCredentialManager;
import org.keycloak.models.UserModel;
import org.keycloak.models.SubjectCredentialManager;
import org.keycloak.models.credential.dto.WebAuthnCredentialData;
import java.io.Serializable;
@ -55,11 +55,11 @@ public class WebAuthnDataWrapper implements Serializable {
final UserModel user = session.users().getUserByUsername(session.getContext().getRealm(), username);
if (user == null) return;
final UserCredentialManager userCredentialManager = session.userCredentialManager();
SubjectCredentialManager userCredentialManager = user.credentialManager();
if (userCredentialManager == null) return;
final CredentialModel credential = userCredentialManager
.getStoredCredentialsByTypeStream(session.getContext().getRealm(), user, credentialType)
.getStoredCredentialsByTypeStream(credentialType)
.findFirst()
.orElse(null);