Delete SearchableModelField and its usages

Signed-off-by: vramik <vramik@redhat.com>

Closes #24722
This commit is contained in:
vramik 2023-11-13 23:48:41 +01:00 committed by Alexander Schwartz
parent 5fad76070a
commit 42e5055cfb
18 changed files with 35 additions and 360 deletions

View file

@ -16,55 +16,34 @@
*/ */
package org.keycloak.authorization.model; package org.keycloak.authorization.model;
import org.keycloak.storage.SearchableModelField;
/** /**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a> * @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
*/ */
public interface PermissionTicket { public interface PermissionTicket {
public static class SearchableFields {
public static final SearchableModelField<PermissionTicket> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<PermissionTicket> RESOURCE_ID = new SearchableModelField<>("resourceId", String.class);
public static final SearchableModelField<PermissionTicket> RESOURCE_SERVER_ID = new SearchableModelField<>("resourceServerId", String.class);
public static final SearchableModelField<PermissionTicket> OWNER = new SearchableModelField<>("owner", String.class);
public static final SearchableModelField<PermissionTicket> REQUESTER = new SearchableModelField<>("requester", String.class);
public static final SearchableModelField<PermissionTicket> SCOPE_ID = new SearchableModelField<>("scopeId", String.class);
public static final SearchableModelField<PermissionTicket> POLICY_ID = new SearchableModelField<>("policyId", String.class);
public static final SearchableModelField<PermissionTicket> GRANTED_TIMESTAMP = new SearchableModelField<>("grantedTimestamp", String.class);
public static final SearchableModelField<PermissionTicket> REALM_ID = new SearchableModelField<>("realmId", String.class);
}
public static enum FilterOption { public static enum FilterOption {
ID("id", SearchableFields.ID), ID("id"),
RESOURCE_ID("resource.id", SearchableFields.RESOURCE_ID), RESOURCE_ID("resource.id"),
RESOURCE_NAME("resource.name", SearchableFields.RESOURCE_ID), RESOURCE_NAME("resource.name"),
SCOPE_ID("scope.id", SearchableFields.SCOPE_ID), SCOPE_ID("scope.id"),
SCOPE_IS_NULL("scope_is_null", SearchableFields.SCOPE_ID), SCOPE_IS_NULL("scope_is_null"),
OWNER("owner", SearchableFields.OWNER), OWNER("owner"),
GRANTED("granted", SearchableFields.GRANTED_TIMESTAMP), GRANTED("granted"),
REQUESTER("requester", SearchableFields.REQUESTER), REQUESTER("requester"),
REQUESTER_IS_NULL("requester_is_null", SearchableFields.REQUESTER), REQUESTER_IS_NULL("requester_is_null"),
POLICY_IS_NOT_NULL("policy_is_not_null", SearchableFields.POLICY_ID), POLICY_IS_NOT_NULL("policy_is_not_null"),
POLICY_ID("policy.id", SearchableFields.POLICY_ID) POLICY_ID("policy.id")
; ;
private final String name; private final String name;
private final SearchableModelField<PermissionTicket> searchableModelField;
FilterOption(String name, SearchableModelField<PermissionTicket> searchableModelField) { FilterOption(String name) {
this.name = name; this.name = name;
this.searchableModelField = searchableModelField;
} }
public String getName() { public String getName() {
return name; return name;
} }
public SearchableModelField<PermissionTicket> getSearchableModelField() {
return searchableModelField;
}
} }
/** /**

View file

@ -20,7 +20,6 @@ package org.keycloak.authorization.model;
import org.keycloak.representations.idm.authorization.DecisionStrategy; import org.keycloak.representations.idm.authorization.DecisionStrategy;
import org.keycloak.representations.idm.authorization.Logic; import org.keycloak.representations.idm.authorization.Logic;
import org.keycloak.storage.SearchableModelField;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -32,47 +31,27 @@ import java.util.Set;
*/ */
public interface Policy { public interface Policy {
public static class SearchableFields {
public static final SearchableModelField<Policy> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<Policy> NAME = new SearchableModelField<>("name", String.class);
public static final SearchableModelField<Policy> RESOURCE_SERVER_ID = new SearchableModelField<>("resourceServerId", String.class);
public static final SearchableModelField<Policy> RESOURCE_ID = new SearchableModelField<>("resourceId", String.class);
public static final SearchableModelField<Policy> SCOPE_ID = new SearchableModelField<>("scopeId", String.class);
public static final SearchableModelField<Policy> TYPE = new SearchableModelField<>("type", String.class);
public static final SearchableModelField<Policy> OWNER = new SearchableModelField<>("owner", String.class);
public static final SearchableModelField<Policy> CONFIG = new SearchableModelField<>("config", String.class);
public static final SearchableModelField<Policy> ASSOCIATED_POLICY_ID = new SearchableModelField<>("associatedPolicyId", String.class);
public static final SearchableModelField<Policy> REALM_ID = new SearchableModelField<>("realmId", String.class);
}
public static enum FilterOption { public static enum FilterOption {
ID("id", SearchableFields.ID), ID("id"),
PERMISSION("permission", SearchableFields.TYPE), PERMISSION("permission"),
OWNER("owner", SearchableFields.OWNER), OWNER("owner"),
ANY_OWNER("owner.any", SearchableFields.OWNER), ANY_OWNER("owner.any"),
RESOURCE_ID("resources.id", SearchableFields.RESOURCE_ID), RESOURCE_ID("resources.id"),
SCOPE_ID("scopes.id", SearchableFields.SCOPE_ID), SCOPE_ID("scopes.id"),
CONFIG("config", SearchableFields.CONFIG), CONFIG("config"),
TYPE("type", SearchableFields.TYPE), TYPE("type"),
NAME("name", SearchableFields.NAME); NAME("name");
public static final String[] EMPTY_FILTER = new String[0]; public static final String[] EMPTY_FILTER = new String[0];
private final String name; private final String name;
private final SearchableModelField<Policy> searchableModelField;
FilterOption(String name, SearchableModelField<Policy> searchableModelField) { FilterOption(String name) {
this.name = name; this.name = name;
this.searchableModelField = searchableModelField;
} }
public String getName() { public String getName() {
return name; return name;
} }
public SearchableModelField<Policy> getSearchableModelField() {
return searchableModelField;
}
} }
public static final String CONFIG_SEPARATOR = "##"; public static final String CONFIG_SEPARATOR = "##";

View file

@ -18,8 +18,6 @@
package org.keycloak.authorization.model; package org.keycloak.authorization.model;
import org.keycloak.storage.SearchableModelField;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -31,46 +29,26 @@ import java.util.Set;
*/ */
public interface Resource { public interface Resource {
public static class SearchableFields {
public static final SearchableModelField<Resource> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<Resource> NAME = new SearchableModelField<>("name", String.class);
public static final SearchableModelField<Resource> RESOURCE_SERVER_ID = new SearchableModelField<>("resourceServerId", String.class);
public static final SearchableModelField<Resource> OWNER = new SearchableModelField<>("owner", String.class);
public static final SearchableModelField<Resource> TYPE = new SearchableModelField<>("type", String.class);
public static final SearchableModelField<Resource> REALM_ID = new SearchableModelField<>("realmId", String.class);
public static final SearchableModelField<Resource> URI = new SearchableModelField<>("uris", String.class);
public static final SearchableModelField<Resource> SCOPE_ID = new SearchableModelField<>("scope", String.class);
public static final SearchableModelField<Resource> OWNER_MANAGED_ACCESS = new SearchableModelField<>("ownerManagedAccess", Boolean.class);
}
public static enum FilterOption { public static enum FilterOption {
ID("id", SearchableFields.ID), ID("id"),
NAME("name", SearchableFields.NAME), NAME("name"),
EXACT_NAME("name", SearchableFields.NAME), EXACT_NAME("name"),
OWNER("owner", SearchableFields.OWNER), OWNER("owner"),
TYPE("type", SearchableFields.TYPE), TYPE("type"),
URI("uri", SearchableFields.URI), URI("uri"),
URI_NOT_NULL("uri_not_null", SearchableFields.URI), URI_NOT_NULL("uri_not_null"),
OWNER_MANAGED_ACCESS("ownerManagedAccess", SearchableFields.OWNER_MANAGED_ACCESS), OWNER_MANAGED_ACCESS("ownerManagedAccess"),
SCOPE_ID("scopes.id", SearchableFields.SCOPE_ID); SCOPE_ID("scopes.id");
private final String name; private final String name;
private final SearchableModelField<Resource> searchableModelField;
FilterOption(String name, SearchableModelField<Resource> searchableModelField) { FilterOption(String name) {
this.name = name; this.name = name;
this.searchableModelField = searchableModelField;
} }
public String getName() { public String getName() {
return name; return name;
} }
public SearchableModelField<Resource> getSearchableModelField() {
return searchableModelField;
}
} }

View file

@ -21,8 +21,6 @@ package org.keycloak.authorization.model;
import org.keycloak.models.RealmModel; import org.keycloak.models.RealmModel;
import org.keycloak.representations.idm.authorization.DecisionStrategy; import org.keycloak.representations.idm.authorization.DecisionStrategy;
import org.keycloak.representations.idm.authorization.PolicyEnforcementMode; import org.keycloak.representations.idm.authorization.PolicyEnforcementMode;
import org.keycloak.storage.SearchableModelField;
/** /**
* Represents a resource server, whose resources are managed and protected. A resource server is basically an existing * Represents a resource server, whose resources are managed and protected. A resource server is basically an existing
@ -32,13 +30,6 @@ import org.keycloak.storage.SearchableModelField;
*/ */
public interface ResourceServer { public interface ResourceServer {
public static class SearchableFields {
public static final SearchableModelField<ResourceServer> ID = new SearchableModelField<>("id", String.class);
/** ID of the client (not the clientId) associated with resource server*/
public static final SearchableModelField<ResourceServer> CLIENT_ID = new SearchableModelField<>("clientId", String.class);
public static final SearchableModelField<ResourceServer> REALM_ID = new SearchableModelField<>("realmId", String.class);
}
/** /**
* Returns the unique identifier for this instance. * Returns the unique identifier for this instance.
* *

View file

@ -18,8 +18,6 @@
package org.keycloak.authorization.model; package org.keycloak.authorization.model;
import org.keycloak.storage.SearchableModelField;
/** /**
* Represents a scope, which is usually associated with one or more resources in order to define the actions that can be performed * Represents a scope, which is usually associated with one or more resources in order to define the actions that can be performed
* or a specific access context. * or a specific access context.
@ -28,33 +26,19 @@ import org.keycloak.storage.SearchableModelField;
*/ */
public interface Scope { public interface Scope {
public static class SearchableFields {
public static final SearchableModelField<Scope> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<Scope> NAME = new SearchableModelField<>("name", String.class);
public static final SearchableModelField<Scope> RESOURCE_SERVER_ID = new SearchableModelField<>("resourceServerId", String.class);
public static final SearchableModelField<Scope> REALM_ID = new SearchableModelField<>("realmId", String.class);
}
public static enum FilterOption { public static enum FilterOption {
ID("id", SearchableFields.ID), ID("id"),
NAME("name", SearchableFields.NAME); NAME("name");
private final String name; private final String name;
private final SearchableModelField<Scope> searchableModelField;
FilterOption(String name, SearchableModelField<Scope> searchableModelField) { FilterOption(String name) {
this.name = name; this.name = name;
this.searchableModelField = searchableModelField;
} }
public String getName() { public String getName() {
return name; return name;
} }
public SearchableModelField<Scope> getSearchableModelField() {
return searchableModelField;
}
} }
/** /**

View file

@ -17,8 +17,6 @@
package org.keycloak.events; package org.keycloak.events;
import org.keycloak.storage.SearchableModelField;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -27,16 +25,6 @@ import java.util.Map;
*/ */
public class Event { public class Event {
public static class SearchableFields {
public static final SearchableModelField<Event> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<Event> REALM_ID = new SearchableModelField<>("realmId", String.class);
public static final SearchableModelField<Event> CLIENT_ID = new SearchableModelField<>("clientId", String.class);
public static final SearchableModelField<Event> USER_ID = new SearchableModelField<>("userId", String.class);
public static final SearchableModelField<Event> TIMESTAMP = new SearchableModelField<>("timestamp", Long.class);
public static final SearchableModelField<Event> IP_ADDRESS = new SearchableModelField<>("ipAddress", String.class);
public static final SearchableModelField<Event> EVENT_TYPE = new SearchableModelField<>("eventType", EventType.class);
}
private String id; private String id;
private long time; private long time;

View file

@ -17,26 +17,11 @@
package org.keycloak.events.admin; package org.keycloak.events.admin;
import org.keycloak.storage.SearchableModelField;
/** /**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a> * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
*/ */
public class AdminEvent { public class AdminEvent {
public static class SearchableFields {
public static final SearchableModelField<AdminEvent> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<AdminEvent> REALM_ID = new SearchableModelField<>("realmId", String.class);
public static final SearchableModelField<AdminEvent> TIMESTAMP = new SearchableModelField<>("timestamp", Long.class);
public static final SearchableModelField<AdminEvent> AUTH_REALM_ID = new SearchableModelField<>("authRealmId", String.class);
public static final SearchableModelField<AdminEvent> AUTH_CLIENT_ID = new SearchableModelField<>("authClientId", String.class);
public static final SearchableModelField<AdminEvent> AUTH_USER_ID = new SearchableModelField<>("authUserId", String.class);
public static final SearchableModelField<AdminEvent> AUTH_IP_ADDRESS = new SearchableModelField<>("authIpAddress", String.class);
public static final SearchableModelField<AdminEvent> OPERATION_TYPE = new SearchableModelField<>("operationType", OperationType.class);
public static final SearchableModelField<AdminEvent> RESOURCE_TYPE = new SearchableModelField<>("resourceType", String.class);
public static final SearchableModelField<AdminEvent> RESOURCE_PATH = new SearchableModelField<>("resourcePath", String.class);
}
private String id; private String id;
private long time; private long time;

View file

@ -24,7 +24,6 @@ import java.util.Set;
import org.keycloak.common.util.ObjectUtil; import org.keycloak.common.util.ObjectUtil;
import org.keycloak.provider.ProviderEvent; import org.keycloak.provider.ProviderEvent;
import org.keycloak.provider.ProviderEventManager; import org.keycloak.provider.ProviderEventManager;
import org.keycloak.storage.SearchableModelField;
/** /**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
@ -41,23 +40,6 @@ public interface ClientModel extends ClientScopeModel, RoleContainerModel, Prot
String POLICY_URI ="policyUri"; String POLICY_URI ="policyUri";
String TOS_URI ="tosUri"; String TOS_URI ="tosUri";
public static class SearchableFields {
public static final SearchableModelField<ClientModel> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<ClientModel> REALM_ID = new SearchableModelField<>("realmId", String.class);
public static final SearchableModelField<ClientModel> CLIENT_ID = new SearchableModelField<>("clientId", String.class);
public static final SearchableModelField<ClientModel> ENABLED = new SearchableModelField<>("enabled", Boolean.class);
public static final SearchableModelField<ClientModel> SCOPE_MAPPING_ROLE = new SearchableModelField<>("scopeMappingRole", String.class);
public static final SearchableModelField<ClientModel> ALWAYS_DISPLAY_IN_CONSOLE = new SearchableModelField<>("alwaysDisplayInConsole", Boolean.class);
/**
* Search for attribute value. The parameters is a pair {@code (attribute_name, value)} where {@code attribute_name}
* is always checked for equality, and the value is checked per the operator.
*/
public static final SearchableModelField<ClientModel> ATTRIBUTE = new SearchableModelField<>("attribute", String[].class);
public static final SearchableModelField<ClientModel> AUTHENTICATION_FLOW_BINDING_OVERRIDE = new SearchableModelField<>("authenticationFlowBindingOverrides", String[].class);
}
interface ClientCreationEvent extends ProviderEvent { interface ClientCreationEvent extends ProviderEvent {
ClientModel getCreatedClient(); ClientModel getCreatedClient();
} }

View file

@ -18,11 +18,9 @@
package org.keycloak.models; package org.keycloak.models;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import org.keycloak.common.util.ObjectUtil; import org.keycloak.common.util.ObjectUtil;
import org.keycloak.provider.ProviderEvent; import org.keycloak.provider.ProviderEvent;
import org.keycloak.storage.SearchableModelField;
/** /**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
@ -30,12 +28,6 @@ import org.keycloak.storage.SearchableModelField;
*/ */
public interface ClientScopeModel extends ProtocolMapperContainerModel, ScopeContainerModel, OrderedModel { public interface ClientScopeModel extends ProtocolMapperContainerModel, ScopeContainerModel, OrderedModel {
public static class SearchableFields {
public static final SearchableModelField<ClientScopeModel> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<ClientScopeModel> REALM_ID = new SearchableModelField<>("realmId", String.class);
public static final SearchableModelField<ClientScopeModel> NAME = new SearchableModelField<>("name", String.class);
}
interface ClientScopeRemovedEvent extends ProviderEvent { interface ClientScopeRemovedEvent extends ProviderEvent {
ClientScopeModel getClientScope(); ClientScopeModel getClientScope();

View file

@ -19,7 +19,6 @@ package org.keycloak.models;
import org.keycloak.provider.ProviderEvent; import org.keycloak.provider.ProviderEvent;
import org.keycloak.storage.SearchableModelField;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -31,25 +30,6 @@ import java.util.stream.Stream;
*/ */
public interface GroupModel extends RoleMapperModel { public interface GroupModel extends RoleMapperModel {
public static class SearchableFields {
public static final SearchableModelField<GroupModel> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<GroupModel> REALM_ID = new SearchableModelField<>("realmId", String.class);
/** Parent group ID */
public static final SearchableModelField<GroupModel> PARENT_ID = new SearchableModelField<>("parentGroupId", String.class);
public static final SearchableModelField<GroupModel> NAME = new SearchableModelField<>("name", String.class);
/**
* Field for comparison with roles granted to this group.
* A role can be checked for belonging only via EQ operator. Role is referred by their ID
*/
public static final SearchableModelField<GroupModel> ASSIGNED_ROLE = new SearchableModelField<>("assignedRole", String.class);
/**
* Search for attribute value. The parameters is a pair {@code (attribute_name, values...)} where {@code attribute_name}
* is always checked for equality, and the value is checked per the operator.
*/
public static final SearchableModelField<GroupModel> ATTRIBUTE = new SearchableModelField<>("attribute", String[].class);
}
interface GroupRemovedEvent extends ProviderEvent { interface GroupRemovedEvent extends ProviderEvent {
RealmModel getRealm(); RealmModel getRealm();
GroupModel getGroup(); GroupModel getGroup();

View file

@ -22,7 +22,6 @@ import org.keycloak.common.enums.SslRequired;
import org.keycloak.component.ComponentModel; import org.keycloak.component.ComponentModel;
import org.keycloak.provider.Provider; import org.keycloak.provider.Provider;
import org.keycloak.provider.ProviderEvent; import org.keycloak.provider.ProviderEvent;
import org.keycloak.storage.SearchableModelField;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -36,19 +35,6 @@ public interface RealmModel extends RoleContainerModel {
Comparator<RealmModel> COMPARE_BY_NAME = Comparator.comparing(RealmModel::getName); Comparator<RealmModel> COMPARE_BY_NAME = Comparator.comparing(RealmModel::getName);
public static class SearchableFields {
public static final SearchableModelField<RealmModel> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<RealmModel> NAME = new SearchableModelField<>("name", String.class);
/**
* Search for realms that have some client initial access set.
*/
public static final SearchableModelField<RealmModel> CLIENT_INITIAL_ACCESS = new SearchableModelField<>("clientInitialAccess", Boolean.class);
/**
* Search for realms that have some component with
*/
public static final SearchableModelField<RealmModel> COMPONENT_PROVIDER_TYPE = new SearchableModelField<>("componentProviderType", String.class);
}
interface RealmCreationEvent extends ProviderEvent { interface RealmCreationEvent extends ProviderEvent {
RealmModel getCreatedRealm(); RealmModel getCreatedRealm();
KeycloakSession getKeycloakSession(); KeycloakSession getKeycloakSession();

View file

@ -18,7 +18,6 @@
package org.keycloak.models; package org.keycloak.models;
import org.keycloak.provider.ProviderEvent; import org.keycloak.provider.ProviderEvent;
import org.keycloak.storage.SearchableModelField;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -29,16 +28,6 @@ import java.util.stream.Stream;
*/ */
public interface RoleModel { public interface RoleModel {
public static class SearchableFields {
public static final SearchableModelField<RoleModel> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<RoleModel> REALM_ID = new SearchableModelField<>("realmId", String.class);
/** If client role, ID of the client (not the clientId) */
public static final SearchableModelField<RoleModel> CLIENT_ID = new SearchableModelField<>("clientId", String.class);
public static final SearchableModelField<RoleModel> NAME = new SearchableModelField<>("name", String.class);
public static final SearchableModelField<RoleModel> DESCRIPTION = new SearchableModelField<>("description", String.class);
public static final SearchableModelField<RoleModel> COMPOSITE_ROLE = new SearchableModelField<>("compositeRoles", Boolean.class);
}
interface RoleNameChangeEvent extends ProviderEvent { interface RoleNameChangeEvent extends ProviderEvent {
RealmModel getRealm(); RealmModel getRealm();
String getNewName(); String getNewName();

View file

@ -16,8 +16,6 @@
*/ */
package org.keycloak.models; package org.keycloak.models;
import org.keycloak.storage.SearchableModelField;
import java.util.Map; import java.util.Map;
/** /**
@ -26,11 +24,6 @@ import java.util.Map;
*/ */
public interface SingleUseObjectValueModel { public interface SingleUseObjectValueModel {
class SearchableFields {
public static final SearchableModelField<SingleUseObjectValueModel> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<SingleUseObjectValueModel> OBJECT_KEY = new SearchableModelField<>("objectKey", String.class);
}
/** /**
* Returns unmodifiable map of all notes. * Returns unmodifiable map of all notes.
* @return see description. Returns empty map if no note is set, never returns {@code null}. * @return see description. Returns empty map if no note is set, never returns {@code null}.

View file

@ -17,20 +17,12 @@
package org.keycloak.models; package org.keycloak.models;
import org.keycloak.storage.SearchableModelField;
/** /**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $ * @version $Revision: 1 $
*/ */
public interface UserLoginFailureModel { public interface UserLoginFailureModel {
class SearchableFields {
public static final SearchableModelField<UserLoginFailureModel> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<UserLoginFailureModel> REALM_ID = new SearchableModelField<>("realmId", String.class);
public static final SearchableModelField<UserLoginFailureModel> USER_ID = new SearchableModelField<>("userId", String.class);
}
String getId(); String getId();
String getUserId(); String getUserId();
int getFailedLoginNotBefore(); int getFailedLoginNotBefore();

View file

@ -18,7 +18,6 @@
package org.keycloak.models; package org.keycloak.models;
import org.keycloak.provider.ProviderEvent; import org.keycloak.provider.ProviderEvent;
import org.keycloak.storage.SearchableModelField;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -47,58 +46,6 @@ public interface UserModel extends RoleMapperModel {
Comparator<UserModel> COMPARE_BY_USERNAME = Comparator.comparing(UserModel::getUsername, String.CASE_INSENSITIVE_ORDER); Comparator<UserModel> COMPARE_BY_USERNAME = Comparator.comparing(UserModel::getUsername, String.CASE_INSENSITIVE_ORDER);
public static class SearchableFields {
public static final SearchableModelField<UserModel> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<UserModel> REALM_ID = new SearchableModelField<>("realmId", String.class);
public static final SearchableModelField<UserModel> FIRST_NAME = new SearchableModelField<>("firstName", String.class);
public static final SearchableModelField<UserModel> LAST_NAME = new SearchableModelField<>("lastName", String.class);
public static final SearchableModelField<UserModel> EMAIL = new SearchableModelField<>("email", String.class);
public static final SearchableModelField<UserModel> ENABLED = new SearchableModelField<>("enabled", Boolean.class);
public static final SearchableModelField<UserModel> EMAIL_VERIFIED = new SearchableModelField<>("emailVerified", Boolean.class);
public static final SearchableModelField<UserModel> FEDERATION_LINK = new SearchableModelField<>("federationLink", String.class);
/**
* Search for user's username in case sensitive mode.
*/
public static final SearchableModelField<UserModel> USERNAME = new SearchableModelField<>("username", String.class);
/**
* Search for user's username in case insensitive mode.
*/
public static final SearchableModelField<UserModel> USERNAME_CASE_INSENSITIVE = new SearchableModelField<>("usernameCaseInsensitive", String.class);
/**
* This field can only searched either for users coming from an IDP, then the operand is (idp_alias),
* or as user coming from a particular IDP with given username there, then the operand is a pair (idp_alias, idp_user_id).
* It is also possible to search regardless of {@code idp_alias}, then the pair is {@code (null, idp_user_id)}.
*/
public static final SearchableModelField<UserModel> IDP_AND_USER = new SearchableModelField<>("idpAlias:idpUserId", String.class);
public static final SearchableModelField<UserModel> ASSIGNED_ROLE = new SearchableModelField<>("assignedRole", String.class);
public static final SearchableModelField<UserModel> ASSIGNED_GROUP = new SearchableModelField<>("assignedGroup", String.class);
/**
* Search for users that have consent set for a particular client.
*/
public static final SearchableModelField<UserModel> CONSENT_FOR_CLIENT = new SearchableModelField<>("clientConsent", String.class);
/**
* Search for users that have consent set for a particular client that originates in the given client provider.
*/
public static final SearchableModelField<UserModel> CONSENT_CLIENT_FEDERATION_LINK = new SearchableModelField<>("clientConsentFederationLink", String.class);
/**
* Search for users that have consent that has given client scope.
*/
public static final SearchableModelField<UserModel> CONSENT_WITH_CLIENT_SCOPE = new SearchableModelField<>("consentWithClientScope", String.class);
/**
* ID of the client corresponding to the service account
*/
public static final SearchableModelField<UserModel> SERVICE_ACCOUNT_CLIENT = new SearchableModelField<>("serviceAccountClientId", String.class);
/**
* Search for attribute value. The parameters is a pair {@code (attribute_name, values...)} where {@code attribute_name}
* is always checked for equality, and the value (which can be any numbert of values, none for operators like EXISTS
* or potentially many for e.g. IN) is checked per the operator.
*/
public static final SearchableModelField<UserModel> ATTRIBUTE = new SearchableModelField<>("attribute", String[].class);
}
interface UserRemovedEvent extends ProviderEvent { interface UserRemovedEvent extends ProviderEvent {
RealmModel getRealm(); RealmModel getRealm();
UserModel getUser(); UserModel getUser();

View file

@ -17,8 +17,6 @@
package org.keycloak.models; package org.keycloak.models;
import org.keycloak.storage.SearchableModelField;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -29,23 +27,6 @@ import org.keycloak.util.EnumWithStableIndex;
*/ */
public interface UserSessionModel { public interface UserSessionModel {
class SearchableFields {
public static final SearchableModelField<UserSessionModel> ID = new SearchableModelField<>("id", String.class);
/**
* Represents the corresponding offline user session for the online user session.
* null if there is no corresponding offline user session.
*/
public static final SearchableModelField<UserSessionModel> CORRESPONDING_SESSION_ID = new SearchableModelField<>("correspondingSessionId", String.class);
public static final SearchableModelField<UserSessionModel> REALM_ID = new SearchableModelField<>("realmId", String.class);
public static final SearchableModelField<UserSessionModel> USER_ID = new SearchableModelField<>("userId", String.class);
public static final SearchableModelField<UserSessionModel> CLIENT_ID = new SearchableModelField<>("clientId", String.class);
public static final SearchableModelField<UserSessionModel> BROKER_SESSION_ID = new SearchableModelField<>("brokerSessionId", String.class);
public static final SearchableModelField<UserSessionModel> BROKER_USER_ID = new SearchableModelField<>("brokerUserId", String.class);
public static final SearchableModelField<UserSessionModel> IS_OFFLINE = new SearchableModelField<>("isOffline", Boolean.class);
public static final SearchableModelField<UserSessionModel> LAST_SESSION_REFRESH = new SearchableModelField<>("lastSessionRefresh", Long.class);
}
/** /**
* Represents the corresponding online/offline user session. * Represents the corresponding online/offline user session.
*/ */

View file

@ -21,7 +21,6 @@ import java.util.Map;
import org.keycloak.models.ClientModel; import org.keycloak.models.ClientModel;
import org.keycloak.models.RealmModel; import org.keycloak.models.RealmModel;
import org.keycloak.storage.SearchableModelField;
/** /**
* Represents usually one browser session with potentially many browser tabs. Every browser tab is represented by * Represents usually one browser session with potentially many browser tabs. Every browser tab is represented by
@ -31,11 +30,6 @@ import org.keycloak.storage.SearchableModelField;
*/ */
public interface RootAuthenticationSessionModel { public interface RootAuthenticationSessionModel {
public static class SearchableFields {
public static final SearchableModelField<RootAuthenticationSessionModel> ID = new SearchableModelField<>("id", String.class);
public static final SearchableModelField<RootAuthenticationSessionModel> REALM_ID = new SearchableModelField<>("realmId", String.class);
}
/** /**
* Returns id of the root authentication session. * Returns id of the root authentication session.
* @return {@code String} * @return {@code String}

View file

@ -1,45 +0,0 @@
/*
* Copyright 2021 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.
*/
package org.keycloak.storage;
/**
*
* @author hmlnarik
*/
public class SearchableModelField<M> {
private final String name;
private final Class<?> fieldClass;
public SearchableModelField(String name, Class<?> fieldClass) {
this.name = name;
this.fieldClass = fieldClass;
}
public String getName() {
return this.name;
}
public Class<?> getFieldType() {
return fieldClass;
}
@Override
public String toString() {
return "SearchableModelField " + name + " @ " + getClass().getTypeParameters()[0].getTypeName();
}
}