Package org.keycloak.authorization.store
Interface ResourceStore
- All Known Implementing Classes:
JPAResourceStore,StoreFactoryCacheSession.ResourceCache
public interface ResourceStore
A
ResourceStore is responsible to manage the persistence of Resource instances.- Author:
- Pedro Igor
-
Method Summary
Modifier and TypeMethodDescriptiondefault Resourcecreate(ResourceServer resourceServer, String name, String owner) Creates aResourceinstance backed by this persistent storage implementation.create(ResourceServer resourceServer, String id, String name, String owner) Creates aResourceinstance backed by this persistent storage implementation.voidRemoves aResourceinstance, with the givenidfrom the persistent storage.find(ResourceServer resourceServer, Map<Resource.FilterOption, String[]> attributes, Integer firstResult, Integer maxResults) Finds allResourceinstances associated with a given resource server.findById(ResourceServer resourceServer, String id) Returns aResourceinstance based on its identifier.default ResourcefindByName(ResourceServer resourceServer, String name) Find aResourceby its name where the owner is the resource server itself.findByName(ResourceServer resourceServer, String name, String ownerId) Find aResourceby its name where the owner is the givenownerId.findByOwner(ResourceServer resourceServer, String ownerId) Finds allResourceinstances with the givenownerId.voidfindByOwner(ResourceServer resourceServer, String ownerId, Consumer<Resource> consumer) Effectively the same method asfindByOwner(ResourceServer, String), however in the end theconsumeris fed with the result.findByResourceServer(ResourceServer resourceServer) Finds allResourceinstances associated with a given resource server.findByScopes(ResourceServer resourceServer, Set<Scope> scopes) Finds allResourceassociated with a given scope.voidfindByScopes(ResourceServer resourceServer, Set<Scope> scopes, Consumer<Resource> consumer) findByType(ResourceServer resourceServer, String type) Finds allResourceassociated with theResourceServerwith the given type.voidfindByType(ResourceServer resourceServer, String type, String owner, Consumer<Resource> consumer) Finds allResourcewith the given type.voidfindByType(ResourceServer resourceServer, String type, Consumer<Resource> consumer) Finds allResourcefromResourceServerwith the given type.voidfindByTypeInstance(ResourceServer resourceServer, String type, Consumer<Resource> consumer) Finds allResourceby type where client represented by theresourceServeris not the owner
-
Method Details
-
create
Creates a
Resourceinstance backed by this persistent storage implementation.- Parameters:
resourceServer- the resource server to where the given resource belongs to. Cannot benull.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
-
create
Creates a
Resourceinstance backed by this persistent storage implementation.- 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
Removes aResourceinstance, with the givenidfrom the persistent storage.- Parameters:
id- the identifier of an existing resource instance
-
findById
Returns aResourceinstance based on its identifier.- Parameters:
resourceServer- the resource server. Ignored ifnullid- the identifier of an existing resource instance- Returns:
- the resource instance with the given identifier or null if no instance was found
-
findByOwner
Finds allResourceinstances with the givenownerId.- Parameters:
resourceServer- resource server. Ignored ifnullownerId- the identifier of the owner- Returns:
- a list with all resource instances owned by the given owner
-
findByOwner
Effectively the same method asfindByOwner(ResourceServer, String), however in the end theconsumeris fed with the result. -
findByResourceServer
Finds allResourceinstances associated with a given resource server.- Parameters:
resourceServer- the identifier of the resource server. Searches for resources without a resourceServer ifnull.- Returns:
- a list with all resources associated with the given resource server
-
find
List<Resource> find(ResourceServer resourceServer, Map<Resource.FilterOption, String[]> attributes, Integer firstResult, Integer maxResults) Finds allResourceinstances associated with a given resource server.- Parameters:
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.FilterOptionfirstResult- 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
- Throws:
IllegalArgumentException- when there is an unknown attribute in theattributesmap
-
findByScopes
Finds allResourceassociated with a given scope.- Parameters:
resourceServer- the resource server. Searches for resources without a resourceServer ifnull.scopes- one or more scope identifiers- Returns:
- a list of resources associated with the given scope(s)
-
findByScopes
-
findByName
Find aResourceby its name where the owner is the resource server itself.- Parameters:
resourceServer- the resource server. Searches for resources without a resourceServer ifnull.name- the name of the resource- Returns:
- a resource with the given name
-
findByName
Find aResourceby its name where the owner is the givenownerId.- Parameters:
resourceServer- the identifier of the resource server. Searches for resources without a resourceServer ifnull.name- the name of the resourceownerId- the owner id- Returns:
- a resource with the given name
-
findByType
Finds allResourceassociated with theResourceServerwith the given type.- Parameters:
resourceServer- the resource server. Searches for resources without a resourceServer ifnull.type- the type of the resource- Returns:
- a list of resources with the given type
-
findByType
Finds allResourcefromResourceServerwith the given type.- Parameters:
resourceServer- the resource server id. Searches for resources without a resourceServer ifnull.type- the type of the resourceconsumer- the result consumer
-
findByType
void findByType(ResourceServer resourceServer, String type, String owner, Consumer<Resource> consumer) Finds allResourcewith the given type.- Parameters:
resourceServer- the resource server id. Searches for resources without a resourceServer ifnull.type- the type of the resourceowner- the resource owner or null for any resource with a given typeconsumer- the result consumer
-
findByTypeInstance
Finds allResourceby type where client represented by theresourceServeris not the owner- Parameters:
resourceServer- the resourceServer. Searches for resources without a resourceServer ifnull.type- searched typeconsumer- a consumer that will be fed with the resulting resources
-