Class MapResourceStore
- java.lang.Object
-
- org.keycloak.models.map.authorization.MapResourceStore
-
- All Implemented Interfaces:
ResourceStore
public class MapResourceStore extends Object implements ResourceStore
-
-
Constructor Summary
Constructors Constructor Description MapResourceStore(KeycloakSession session, MapStorage<MapResourceEntity,Resource> resourceStore, AuthorizationProvider provider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resource
create(ResourceServer resourceServer, String id, String name, String owner)
Creates aResource
instance backed by this persistent storage implementation.void
delete(RealmModel realm, String id)
Removes aResource
instance, with the givenid
from the persistent storage.List<Resource>
find(RealmModel realm, ResourceServer resourceServer, Map<Resource.FilterOption,String[]> attributes, Integer firstResult, Integer maxResults)
Finds allResource
instances associated with a given resource server.Resource
findById(RealmModel realm, ResourceServer resourceServer, String id)
Returns aResource
instance based on its identifier.Resource
findByName(ResourceServer resourceServer, String name, String ownerId)
Find aResource
by its name where the owner is the givenownerId
.void
findByOwner(RealmModel realm, ResourceServer resourceServer, String ownerId, Consumer<Resource> consumer)
List<Resource>
findByResourceServer(ResourceServer resourceServer)
Finds allResource
instances associated with a given resource server.void
findByScopes(ResourceServer resourceServer, Set<Scope> scopes, Consumer<Resource> consumer)
void
findByType(ResourceServer resourceServer, String type, String owner, Consumer<Resource> consumer)
Finds allResource
with the given type.void
findByType(ResourceServer resourceServer, String type, Consumer<Resource> consumer)
Finds allResource
fromResourceServer
with the given type.void
findByTypeInstance(ResourceServer resourceServer, String type, Consumer<Resource> consumer)
Finds allResource
by type where client represented by theresourceServer
is not the ownervoid
preRemove(RealmModel realm)
void
preRemove(RealmModel realm, ResourceServer resourceServer)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.keycloak.authorization.store.ResourceStore
create, findByName, findByOwner, findByScopes, findByType
-
-
-
-
Constructor Detail
-
MapResourceStore
public MapResourceStore(KeycloakSession session, MapStorage<MapResourceEntity,Resource> resourceStore, AuthorizationProvider provider)
-
-
Method Detail
-
create
public Resource create(ResourceServer resourceServer, String id, String name, String owner)
Description copied from interface:ResourceStore
Creates a
Resource
instance backed by this persistent storage implementation.- Specified by:
create
in interfaceResourceStore
- Parameters:
resourceServer
- the resource server to where the given resource belongs to. Cannot benull
.id
- the id of this resource. It must be unique. Will be randomly generated if null.name
- the name of this resource. It must be unique.owner
- the owner of this resource or null if the resource server is the owner- Returns:
- an instance backed by the underlying storage implementation
-
delete
public void delete(RealmModel realm, String id)
Description copied from interface:ResourceStore
Removes aResource
instance, with the givenid
from the persistent storage.- Specified by:
delete
in interfaceResourceStore
- Parameters:
realm
- the realm. Cannot benull
.id
- the identifier of an existing resource instance
-
findById
public Resource findById(RealmModel realm, ResourceServer resourceServer, String id)
Description copied from interface:ResourceStore
Returns aResource
instance based on its identifier.- Specified by:
findById
in interfaceResourceStore
- Parameters:
realm
- the realm. Cannot benull
.resourceServer
- the resource server. Ignored ifnull
id
- the identifier of an existing resource instance- Returns:
- the resource instance with the given identifier or null if no instance was found
-
findByOwner
public void findByOwner(RealmModel realm, ResourceServer resourceServer, String ownerId, Consumer<Resource> consumer)
- Specified by:
findByOwner
in interfaceResourceStore
-
findByResourceServer
public List<Resource> findByResourceServer(ResourceServer resourceServer)
Description copied from interface:ResourceStore
Finds allResource
instances associated with a given resource server.- Specified by:
findByResourceServer
in interfaceResourceStore
- Parameters:
resourceServer
- the identifier of the resource server. Cannot benull
.- Returns:
- a list with all resources associated with the given resource server
-
find
public List<Resource> find(RealmModel realm, ResourceServer resourceServer, Map<Resource.FilterOption,String[]> attributes, Integer firstResult, Integer maxResults)
Description copied from interface:ResourceStore
Finds allResource
instances associated with a given resource server.- Specified by:
find
in interfaceResourceStore
- Parameters:
realm
- the realm. Cannot benull
.resourceServer
- the identifier of the resource server. Ignored ifnull
.attributes
- a map holding the attributes that will be used as a filter; possible filter options are given byResource.FilterOption
firstResult
- first result to return. Ignored if negative ornull
.maxResults
- maximum number of results to return. Ignored if negative ornull
.- Returns:
- a list with all resources associated with the given resource server
-
findByScopes
public void findByScopes(ResourceServer resourceServer, Set<Scope> scopes, Consumer<Resource> consumer)
- Specified by:
findByScopes
in interfaceResourceStore
-
findByName
public Resource findByName(ResourceServer resourceServer, String name, String ownerId)
Description copied from interface:ResourceStore
Find aResource
by its name where the owner is the givenownerId
.- Specified by:
findByName
in interfaceResourceStore
- Parameters:
resourceServer
- the identifier of the resource server. Cannot benull
.name
- the name of the resourceownerId
- the owner id- Returns:
- a resource with the given name
-
findByType
public void findByType(ResourceServer resourceServer, String type, Consumer<Resource> consumer)
Description copied from interface:ResourceStore
Finds allResource
fromResourceServer
with the given type.- Specified by:
findByType
in interfaceResourceStore
- Parameters:
resourceServer
- the resource server id. Cannot benull
.type
- the type of the resourceconsumer
- the result consumer
-
findByType
public void findByType(ResourceServer resourceServer, String type, String owner, Consumer<Resource> consumer)
Description copied from interface:ResourceStore
Finds allResource
with the given type.- Specified by:
findByType
in interfaceResourceStore
- Parameters:
resourceServer
- the resource server id. Cannot benull
type
- the type of the resourceowner
- the resource owner or null for any resource with a given typeconsumer
- the result consumer
-
findByTypeInstance
public void findByTypeInstance(ResourceServer resourceServer, String type, Consumer<Resource> consumer)
Description copied from interface:ResourceStore
Finds allResource
by type where client represented by theresourceServer
is not the owner- Specified by:
findByTypeInstance
in interfaceResourceStore
- Parameters:
resourceServer
- the resourceServer. Cannot benull
.type
- searched typeconsumer
- a consumer that will be fed with the resulting resources
-
preRemove
public void preRemove(RealmModel realm)
-
preRemove
public void preRemove(RealmModel realm, ResourceServer resourceServer)
-
-