Package org.keycloak.authorization.store
Interface ResourceStore
-
- All Known Implementing Classes:
JPAResourceStore
,MapResourceStore
,StoreFactoryCacheSession.ResourceCache
public interface ResourceStore
AResourceStore
is responsible to manage the persistence ofResource
instances.- Author:
- Pedro Igor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Resource
create(ResourceServer resourceServer, String name, String owner)
Creates aResource
instance backed by this persistent storage implementation.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.default Resource
findByName(ResourceServer resourceServer, String name)
Find aResource
by its name where the owner is the resource server itself.Resource
findByName(ResourceServer resourceServer, String name, String ownerId)
Find aResource
by its name where the owner is the givenownerId
.default List<Resource>
findByOwner(RealmModel realm, ResourceServer resourceServer, String ownerId)
Finds allResource
instances with 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.default List<Resource>
findByScopes(ResourceServer resourceServer, Set<Scope> scopes)
Finds allResource
associated with a given scope.void
findByScopes(ResourceServer resourceServer, Set<Scope> scopes, Consumer<Resource> consumer)
default List<Resource>
findByType(ResourceServer resourceServer, String type)
Finds allResource
fromResourceServer
with the given type.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 owner
-
-
-
Method Detail
-
create
default Resource create(ResourceServer resourceServer, String name, String owner)
Creates a
Resource
instance 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
Resource create(ResourceServer resourceServer, String id, String name, String owner)
Creates a
Resource
instance 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
void delete(RealmModel realm, String id)
Removes aResource
instance, with the givenid
from the persistent storage.- Parameters:
realm
- the realm. Cannot benull
.id
- the identifier of an existing resource instance
-
findById
Resource findById(RealmModel realm, ResourceServer resourceServer, String id)
Returns aResource
instance based on its identifier.- 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
default List<Resource> findByOwner(RealmModel realm, ResourceServer resourceServer, String ownerId)
Finds allResource
instances with the givenownerId
.- Parameters:
realm
- the realm. Cannot benull
.resourceServer
- resource server. Ignored ifnull
ownerId
- the identifier of the owner- Returns:
- a list with all resource instances owned by the given owner
-
findByOwner
void findByOwner(RealmModel realm, ResourceServer resourceServer, String ownerId, Consumer<Resource> consumer)
-
findByResourceServer
List<Resource> findByResourceServer(ResourceServer resourceServer)
Finds allResource
instances associated with a given resource server.- Parameters:
resourceServer
- the identifier of the resource server. Cannot benull
.- Returns:
- a list with all resources associated with the given resource server
-
find
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.- 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
- Throws:
IllegalArgumentException
- when there is an unknown attribute in theattributes
map
-
findByScopes
default List<Resource> findByScopes(ResourceServer resourceServer, Set<Scope> scopes)
Finds allResource
associated with a given scope.- Parameters:
resourceServer
- the resource server. Cannot benull
.scopes
- one or more scope identifiers- Returns:
- a list of resources associated with the given scope(s)
-
findByScopes
void findByScopes(ResourceServer resourceServer, Set<Scope> scopes, Consumer<Resource> consumer)
-
findByName
default Resource findByName(ResourceServer resourceServer, String name)
Find aResource
by its name where the owner is the resource server itself.- Parameters:
resourceServer
- the resource server. Cannot benull
.name
- the name of the resource- Returns:
- a resource with the given name
-
findByName
Resource findByName(ResourceServer resourceServer, String name, String ownerId)
Find aResource
by its name where the owner is the givenownerId
.- 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
default List<Resource> findByType(ResourceServer resourceServer, String type)
Finds allResource
fromResourceServer
with the given type.- Parameters:
resourceServer
- the resource server. Cannot benull
.type
- the type of the resource- Returns:
- a list of resources with the given type
-
findByType
void findByType(ResourceServer resourceServer, String type, Consumer<Resource> consumer)
Finds allResource
fromResourceServer
with the given type.- Parameters:
resourceServer
- the resource server id. Cannot benull
.type
- the type of the resourceconsumer
- the result consumer
-
findByType
void findByType(ResourceServer resourceServer, String type, String owner, Consumer<Resource> consumer)
Finds allResource
with the given type.- 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
void findByTypeInstance(ResourceServer resourceServer, String type, Consumer<Resource> consumer)
Finds allResource
by type where client represented by theresourceServer
is not the owner- Parameters:
resourceServer
- the resourceServer. Cannot benull
.type
- searched typeconsumer
- a consumer that will be fed with the resulting resources
-
-