Class JPAResourceStore
java.lang.Object
org.keycloak.authorization.jpa.store.JPAResourceStore
- All Implemented Interfaces:
ResourceStore
- Author:
- Pedro Igor
-
Constructor Summary
ConstructorsConstructorDescriptionJPAResourceStore(jakarta.persistence.EntityManager entityManager, AuthorizationProvider provider) -
Method Summary
Modifier and TypeMethodDescriptioncreate(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.findByName(ResourceServer resourceServer, String name, String ownerId) Find aResourceby its name where the owner is the givenownerId.voidfindByOwner(ResourceServer resourceServer, String ownerId, Consumer<Resource> consumer) Effectively the same method asResourceStore.findByOwner(ResourceServer, String), however in the end theconsumeris fed with the result.findByResourceServer(ResourceServer resourceServer) Finds allResourceinstances associated with a given resource server.voidfindByScopes(ResourceServer resourceServer, Set<Scope> scopes, Consumer<Resource> consumer) 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 ownerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.authorization.store.ResourceStore
create, findByName, findByOwner, findByScopes, findByType
-
Constructor Details
-
JPAResourceStore
public JPAResourceStore(jakarta.persistence.EntityManager entityManager, AuthorizationProvider provider)
-
-
Method Details
-
create
Description copied from interface:ResourceStoreCreates a
Resourceinstance backed by this persistent storage implementation.- Specified by:
createin 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
Description copied from interface:ResourceStoreRemoves aResourceinstance, with the givenidfrom the persistent storage.- Specified by:
deletein interfaceResourceStore- Parameters:
id- the identifier of an existing resource instance
-
findById
Description copied from interface:ResourceStoreReturns aResourceinstance based on its identifier.- Specified by:
findByIdin interfaceResourceStore- 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
Description copied from interface:ResourceStoreEffectively the same method asResourceStore.findByOwner(ResourceServer, String), however in the end theconsumeris fed with the result.- Specified by:
findByOwnerin interfaceResourceStore
-
findByResourceServer
Description copied from interface:ResourceStoreFinds allResourceinstances associated with a given resource server.- Specified by:
findByResourceServerin interfaceResourceStore- 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
public List<Resource> find(ResourceServer resourceServer, Map<Resource.FilterOption, String[]> attributes, Integer firstResult, Integer maxResults) Description copied from interface:ResourceStoreFinds allResourceinstances associated with a given resource server.- Specified by:
findin interfaceResourceStore- 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
-
findByScopes
public void findByScopes(ResourceServer resourceServer, Set<Scope> scopes, Consumer<Resource> consumer) - Specified by:
findByScopesin interfaceResourceStore
-
findByName
Description copied from interface:ResourceStoreFind aResourceby its name where the owner is the givenownerId.- Specified by:
findByNamein interfaceResourceStore- 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
Description copied from interface:ResourceStoreFinds allResourcefromResourceServerwith the given type.- Specified by:
findByTypein interfaceResourceStore- Parameters:
resourceServer- the resource server id. Searches for resources without a resourceServer ifnull.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:ResourceStoreFinds allResourcewith the given type.- Specified by:
findByTypein interfaceResourceStore- 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
public void findByTypeInstance(ResourceServer resourceServer, String type, Consumer<Resource> consumer) Description copied from interface:ResourceStoreFinds allResourceby type where client represented by theresourceServeris not the owner- Specified by:
findByTypeInstancein interfaceResourceStore- Parameters:
resourceServer- the resourceServer. Searches for resources without a resourceServer ifnull.type- searched typeconsumer- a consumer that will be fed with the resulting resources
-