Package org.keycloak.authorization.store
Interface ResourceStore
-
public interface ResourceStoreAResourceStoreis responsible to manage the persistence ofResourceinstances.- Author:
- Pedro Igor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Resourcecreate(String id, String name, ResourceServer resourceServer, String owner)Creates aResourceinstance backed by this persistent storage implementation.default Resourcecreate(String name, ResourceServer resourceServer, String owner)Creates aResourceinstance backed by this persistent storage implementation.voiddelete(String id)Removes aResourceinstance, with the givenidfrom the persistent storage.ResourcefindById(String id, String resourceServerId)Returns aResourceinstance based on its identifier.ResourcefindByName(String name, String resourceServerId)Find aResourceby its name where the owner is the resource server itself.ResourcefindByName(String name, String ownerId, String resourceServerId)Find aResourceby its name where the owner is the givenownerId.default List<Resource>findByOwner(String ownerId, String resourceServerId)Finds allResourceinstances with the givenownerId.List<Resource>findByOwner(String ownerId, String resourceServerId, int first, int max)voidfindByOwner(String ownerId, String resourceServerId, Consumer<Resource> consumer)List<Resource>findByResourceServer(String resourceServerId)Finds allResourceinstances associated with a given resource server.List<Resource>findByResourceServer(Map<Resource.FilterOption,String[]> attributes, String resourceServerId, int firstResult, int maxResult)Finds allResourceinstances associated with a given resource server.default List<Resource>findByScope(List<String> id, String resourceServerId)Finds allResourceassociated with a given scope.voidfindByScope(List<String> scopes, String resourceServerId, Consumer<Resource> consumer)default List<Resource>findByType(String type, String resourceServerId)Finds allResourcewith the given type.default List<Resource>findByType(String type, String owner, String resourceServerId)Finds allResourcewith the given type.voidfindByType(String type, String owner, String resourceServerId, Consumer<Resource> consumer)Finds allResourcewith the given type.voidfindByType(String type, String resourceServerId, Consumer<Resource> consumer)Finds allResourcewith the given type.default List<Resource>findByTypeInstance(String type, String resourceServerId)voidfindByTypeInstance(String type, String resourceServerId, Consumer<Resource> consumer)List<Resource>findByUri(String uri, String resourceServerId)Finds allResourceinstances with the given uri.
-
-
-
Method Detail
-
create
default Resource create(String name, ResourceServer resourceServer, String owner)
Creates a
Resourceinstance backed by this persistent storage implementation.- Parameters:
name- the name of this resource. It must be unique.resourceServer- the resource server to where the given resource belongs toowner- 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(String id, String name, ResourceServer resourceServer, String owner)
Creates a
Resourceinstance backed by this persistent storage implementation.- Parameters:
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.resourceServer- the resource server to where the given resource belongs toowner- 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(String id)
Removes aResourceinstance, with the givenidfrom the persistent storage.- Parameters:
id- the identifier of an existing resource instance
-
findById
Resource findById(String id, String resourceServerId)
Returns aResourceinstance based on its identifier.- Parameters:
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(String ownerId, String resourceServerId)
Finds allResourceinstances with the givenownerId.- Parameters:
ownerId- the identifier of the owner- Returns:
- a list with all resource instances owned by the given owner
-
findByOwner
List<Resource> findByOwner(String ownerId, String resourceServerId, int first, int max)
-
findByUri
List<Resource> findByUri(String uri, String resourceServerId)
Finds allResourceinstances with the given uri.- Parameters:
uri- the identifier of the uri- Returns:
- a list with all resource instances owned by the given owner
-
findByResourceServer
List<Resource> findByResourceServer(String resourceServerId)
Finds allResourceinstances associated with a given resource server.- Parameters:
resourceServerId- the identifier of the resource server- Returns:
- a list with all resources associated with the given resource server
-
findByResourceServer
List<Resource> findByResourceServer(Map<Resource.FilterOption,String[]> attributes, String resourceServerId, int firstResult, int maxResult)
Finds allResourceinstances associated with a given resource server.- Parameters:
attributes- a map holding the attributes that will be used as a filter; possible filter options are given byResource.FilterOptionresourceServerId- the identifier of the resource server- Returns:
- a list with all resources associated with the given resource server
- Throws:
IllegalArgumentException- when there is an unknown attribute in theattributesmap
-
findByScope
default List<Resource> findByScope(List<String> id, String resourceServerId)
Finds allResourceassociated with a given scope.- Parameters:
id- one or more scope identifiers- Returns:
- a list of resources associated with the given scope(s)
-
findByScope
void findByScope(List<String> scopes, String resourceServerId, Consumer<Resource> consumer)
-
findByName
Resource findByName(String name, String resourceServerId)
Find aResourceby its name where the owner is the resource server itself.- Parameters:
name- the name of the resourceresourceServerId- the identifier of the resource server- Returns:
- a resource with the given name
-
findByName
Resource findByName(String name, String ownerId, String resourceServerId)
Find aResourceby its name where the owner is the givenownerId.- Parameters:
name- the name of the resourceownerId- the owner idresourceServerId- the identifier of the resource server- Returns:
- a resource with the given name
-
findByType
default List<Resource> findByType(String type, String resourceServerId)
Finds allResourcewith the given type.- Parameters:
type- the type of the resource- Returns:
- a list of resources with the given type
-
findByType
default List<Resource> findByType(String type, String owner, String resourceServerId)
Finds allResourcewith the given type.- Parameters:
type- the type of the resourceowner- the resource owner or null for any resource with a given type- Returns:
- a list of resources with the given type
-
findByType
void findByType(String type, String resourceServerId, Consumer<Resource> consumer)
Finds allResourcewith the given type.- Parameters:
type- the type of the resourceresourceServerId- the resource server idconsumer- the result consumer
-
findByType
void findByType(String type, String owner, String resourceServerId, Consumer<Resource> consumer)
Finds allResourcewith the given type.- Parameters:
type- the type of the resourceowner- the resource owner or null for any resource with a given typeresourceServerId- the resource server idconsumer- the result consumer
-
-