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 default Resourcecreate(ResourceServer resourceServer, String name, String owner)Creates aResourceinstance backed by this persistent storage implementation.Resourcecreate(ResourceServer resourceServer, String id, String name, String owner)Creates aResourceinstance backed by this persistent storage implementation.voiddelete(String id)Removes aResourceinstance, with the givenidfrom the persistent storage.ResourcefindById(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.ResourcefindByName(ResourceServer resourceServer, String name, String ownerId)Find aResourceby its name where the owner is the givenownerId.default List<Resource>findByOwner(ResourceServer resourceServer, String ownerId)Finds allResourceinstances with the givenownerId.List<Resource>findByOwner(ResourceServer resourceServer, String ownerId, Integer firstResult, Integer maxResults)voidfindByOwner(ResourceServer resourceServer, String ownerId, Consumer<Resource> consumer)List<Resource>findByResourceServer(ResourceServer resourceServer)Finds allResourceinstances associated with a given resource server.List<Resource>findByResourceServer(ResourceServer resourceServer, Map<Resource.FilterOption,String[]> attributes, Integer firstResult, Integer maxResults)Finds allResourceinstances associated with a given resource server.default List<Resource>findByScopes(ResourceServer resourceServer, Set<Scope> scopes)Finds allResourceassociated with a given scope.voidfindByScopes(ResourceServer resourceServer, Set<Scope> scopes, Consumer<Resource> consumer)default List<Resource>findByType(ResourceServer resourceServer, String type)Finds allResourcewith the given type.default List<Resource>findByType(ResourceServer resourceServer, String type, String owner)Finds allResourcewith 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 allResourcewith the given type.default List<Resource>findByTypeInstance(ResourceServer resourceServer, String type)voidfindByTypeInstance(ResourceServer resourceServerId, String type, Consumer<Resource> consumer)List<Resource>findByUri(ResourceServer resourceServer, String uri)Finds allResourceinstances with the given uri.
-
-
-
Method Detail
-
create
default Resource create(ResourceServer resourceServer, String name, String owner)
Creates a
Resourceinstance backed by this persistent storage implementation.- Parameters:
resourceServer- the resource server to where the given resource belongs toname- 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
Resourceinstance backed by this persistent storage implementation.- Parameters:
resourceServer- the resource server to where the given resource belongs toid- 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(String id)
Removes aResourceinstance, with the givenidfrom the persistent storage.- Parameters:
id- the identifier of an existing resource instance
-
findById
Resource findById(ResourceServer resourceServer, String id)
Returns aResourceinstance based on its identifier.- Parameters:
resourceServer- the resource serverid- 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(ResourceServer resourceServer, String ownerId)
Finds allResourceinstances with the givenownerId.- Parameters:
resourceServer-ownerId- the identifier of the owner- Returns:
- a list with all resource instances owned by the given owner
-
findByOwner
void findByOwner(ResourceServer resourceServer, String ownerId, Consumer<Resource> consumer)
-
findByOwner
List<Resource> findByOwner(ResourceServer resourceServer, String ownerId, Integer firstResult, Integer maxResults)
-
findByUri
List<Resource> findByUri(ResourceServer resourceServer, String uri)
Finds allResourceinstances with the given uri.- Parameters:
resourceServer-uri- the identifier of the uri- Returns:
- a list with all resource instances owned by the given owner
-
findByResourceServer
List<Resource> findByResourceServer(ResourceServer resourceServer)
Finds allResourceinstances associated with a given resource server.- Parameters:
resourceServer- the identifier of the resource server- Returns:
- a list with all resources associated with the given resource server
-
findByResourceServer
List<Resource> findByResourceServer(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 serverattributes- 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
default List<Resource> findByScopes(ResourceServer resourceServer, Set<Scope> scopes)
Finds allResourceassociated with a given scope.- Parameters:
resourceServer-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 aResourceby its name where the owner is the resource server itself.- Parameters:
resourceServer- the resource servername- the name of the resource- Returns:
- a resource with the given name
-
findByName
Resource findByName(ResourceServer resourceServer, String name, String ownerId)
Find aResourceby its name where the owner is the givenownerId.- Parameters:
resourceServer- the identifier of the resource servername- 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 allResourcewith the given type.- Parameters:
resourceServer-type- the type of the resource- Returns:
- a list of resources with the given type
-
findByType
default List<Resource> findByType(ResourceServer resourceServer, String type, String owner)
Finds allResourcewith the given type.- Parameters:
resourceServer-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(ResourceServer resourceServer, String type, Consumer<Resource> consumer)
Finds allResourcewith the given type.- Parameters:
resourceServer- the resource server idtype- 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 idtype- the type of the resourceowner- the resource owner or null for any resource with a given typeconsumer- the result consumer
-
findByTypeInstance
default List<Resource> findByTypeInstance(ResourceServer resourceServer, String type)
-
findByTypeInstance
void findByTypeInstance(ResourceServer resourceServerId, String type, Consumer<Resource> consumer)
-
-