Package org.keycloak.cache
Class DefaultAlternativeLookupProvider
java.lang.Object
org.keycloak.cache.DefaultAlternativeLookupProvider
- All Implemented Interfaces:
AlternativeLookupProvider,Provider
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()lookupClientFromClientAttributes(KeycloakSession session, Map<String, String> attributes) lookupIdentityProviderFromIssuer(KeycloakSession session, IdentityProviderType type, String issuerUrl) lookupRoleFromString(RealmModel realm, String roleName) Looks up a role from its string representation, supporting both realm and client roles.
-
Method Details
-
lookupIdentityProviderFromIssuer
public IdentityProviderModel lookupIdentityProviderFromIssuer(KeycloakSession session, IdentityProviderType type, String issuerUrl) - Specified by:
lookupIdentityProviderFromIssuerin interfaceAlternativeLookupProvider
-
lookupClientFromClientAttributes
public ClientModel lookupClientFromClientAttributes(KeycloakSession session, Map<String, String> attributes) - Specified by:
lookupClientFromClientAttributesin interfaceAlternativeLookupProvider
-
lookupRoleFromString
Description copied from interface:AlternativeLookupProviderLooks up a role from its string representation, supporting both realm and client roles.The method interprets the
roleNameparameter as follows:- For realm roles: the role name directly (e.g.,
"admin") - For client roles: the format
"client-id.role-name"where the client ID and role name are separated by a dot separator
Since client IDs can contain dots, the method attempts multiple splits from right to left to resolve ambiguous role names. For example,
"my.client.app.role"will first try to look up client"my.client.app"with role"role", then client"my.client"with role"app.role", and so on.The lookup uses caching to reduce database load. If a role is not found in the cache, the method performs a database lookup and caches the result for subsequent calls.
- Specified by:
lookupRoleFromStringin interfaceAlternativeLookupProvider- Parameters:
realm- the realm in which to look up the roleroleName- the string representation of the role name, which can be a realm role name or a client role in the format"client-id.role-name". May benull.- Returns:
- the corresponding
RoleModelif found, ornullif the role does not exist or ifroleNameisnull
- For realm roles: the role name directly (e.g.,
-
close
public void close()
-