Class JPAPolicyStore
- java.lang.Object
- 
- org.keycloak.authorization.jpa.store.JPAPolicyStore
 
- 
- All Implemented Interfaces:
- PolicyStore
 
 public class JPAPolicyStore extends Object implements PolicyStore - Author:
- Pedro Igor
 
- 
- 
Constructor SummaryConstructors Constructor Description JPAPolicyStore(javax.persistence.EntityManager entityManager, AuthorizationProvider provider)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Policycreate(ResourceServer resourceServer, AbstractPolicyRepresentation representation)Creates a newPolicyinstance.voiddelete(RealmModel realm, String id)Deletes a policy from the underlying persistence mechanism.List<Policy>find(RealmModel realm, ResourceServer resourceServer, Map<Policy.FilterOption,String[]> attributes, Integer firstResult, Integer maxResults)PolicyfindById(RealmModel realm, ResourceServer resourceServer, String id)Returns aPolicywith the givenidPolicyfindByName(ResourceServer resourceServer, String name)Returns aPolicywith the givennamevoidfindByResource(ResourceServer resourceServer, Resource resource, Consumer<Policy> consumer)Searches for all policies associated with theResourceand passes the result to theconsumerList<Policy>findByResourceServer(ResourceServer resourceServer)Returns a list ofPolicyassociated with theResourceServervoidfindByResourceType(ResourceServer resourceServer, String resourceType, Consumer<Policy> consumer)Searches for policies associated with aResourceServerand passes the result to the consumerList<Policy>findByScopes(ResourceServer resourceServer, List<Scope> scopes)voidfindByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes, Consumer<Policy> consumer)Effectively the same method asPolicyStore.findByScopes(ResourceServer, Resource, List), however in the end theconsumeris fed with the result.List<Policy>findByType(ResourceServer resourceServer, String type)Returns a list ofPolicywith the giventype.List<Policy>findDependentPolicies(ResourceServer resourceServer, String policyId)Returns a list ofPolicythat depends on another policy with the givenid.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.authorization.store.PolicyStorefindByResource, findByResourceType, findByScopes
 
- 
 
- 
- 
- 
Constructor Detail- 
JPAPolicyStorepublic JPAPolicyStore(javax.persistence.EntityManager entityManager, AuthorizationProvider provider)
 
- 
 - 
Method Detail- 
createpublic Policy create(ResourceServer resourceServer, AbstractPolicyRepresentation representation) Description copied from interface:PolicyStoreCreates a newPolicyinstance. The new instance is not necessarily persisted though, which may require a call to the {#save} method to actually make it persistent.- Specified by:
- createin interface- PolicyStore
- Parameters:
- resourceServer- the resource server to which this policy belongs. Cannot be- null.
- representation- the policy representation
- Returns:
- a new instance of Policy
 
 - 
deletepublic void delete(RealmModel realm, String id) Description copied from interface:PolicyStoreDeletes a policy from the underlying persistence mechanism.- Specified by:
- deletein interface- PolicyStore
- Parameters:
- realm- the realm that the removed policy belongs to. Cannot be- null
- id- the id of the policy to delete
 
 - 
findByIdpublic Policy findById(RealmModel realm, ResourceServer resourceServer, String id) Description copied from interface:PolicyStoreReturns aPolicywith the givenid- Specified by:
- findByIdin interface- PolicyStore
- Parameters:
- realm- the realm. Cannot be- null.
- resourceServer- the resource server. Ignored if- null.
- id- the identifier of the policy
- Returns:
- a policy with the given identifier.
 
 - 
findByNamepublic Policy findByName(ResourceServer resourceServer, String name) Description copied from interface:PolicyStoreReturns aPolicywith the givenname- Specified by:
- findByNamein interface- PolicyStore
- Parameters:
- resourceServer- the resource server. Cannot be- null
- name- the name of the policy
- Returns:
- a policy with the given name or nullif no such policy exists.
 
 - 
findByResourceServerpublic List<Policy> findByResourceServer(ResourceServer resourceServer) Description copied from interface:PolicyStoreReturns a list ofPolicyassociated with theResourceServer- Specified by:
- findByResourceServerin interface- PolicyStore
- Parameters:
- resourceServer- the resource server. Cannot be- null.
- Returns:
- a list of policies that belong to the given resource server
 
 - 
findpublic List<Policy> find(RealmModel realm, ResourceServer resourceServer, Map<Policy.FilterOption,String[]> attributes, Integer firstResult, Integer maxResults) Description copied from interface:PolicyStore- Specified by:
- findin interface- PolicyStore
- Parameters:
- realm- the realm. Cannot be- null.
- resourceServer- the identifier of a resource server. Ignored if- null.
- attributes- a map holding the attributes that will be used as a filter; possible filter options are given by- Policy.FilterOption
- firstResult- first result to return. Ignored if negative or- null.
- maxResults- maximum number of results to return. Ignored if negative or- null.
- Returns:
- a list of policies that belong to the given resource server
 
 - 
findByResourcepublic void findByResource(ResourceServer resourceServer, Resource resource, Consumer<Policy> consumer) Description copied from interface:PolicyStoreSearches for all policies associated with theResourceand passes the result to theconsumer- Specified by:
- findByResourcein interface- PolicyStore
- Parameters:
- resourceServer- the resourceServer. Cannot be- null.
- resource- the resource. Cannot be- null.
- consumer- consumer of policies resulted from the search
 
 - 
findByResourceTypepublic void findByResourceType(ResourceServer resourceServer, String resourceType, Consumer<Policy> consumer) Description copied from interface:PolicyStoreSearches for policies associated with aResourceServerand passes the result to the consumer- Specified by:
- findByResourceTypein interface- PolicyStore
- Parameters:
- resourceServer- the resourceServer. Cannot be- null.
- resourceType- the type of a resource
- consumer- consumer of policies resulted from the search
 
 - 
findByScopespublic List<Policy> findByScopes(ResourceServer resourceServer, List<Scope> scopes) Description copied from interface:PolicyStore- Specified by:
- findByScopesin interface- PolicyStore
- Parameters:
- resourceServer- the resource server. Cannot be- null.
- scopes- the scopes
- Returns:
- a list of policies associated with the given scopes
 
 - 
findByScopespublic void findByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes, Consumer<Policy> consumer) Description copied from interface:PolicyStoreEffectively the same method asPolicyStore.findByScopes(ResourceServer, Resource, List), however in the end theconsumeris fed with the result.- Specified by:
- findByScopesin interface- PolicyStore
 
 - 
findByTypepublic List<Policy> findByType(ResourceServer resourceServer, String type) Description copied from interface:PolicyStoreReturns a list ofPolicywith the giventype.- Specified by:
- findByTypein interface- PolicyStore
- Parameters:
- resourceServer- the resource server id. Cannot be- null.
- type- the type of the policy
- Returns:
- a list of policies with the given type
 
 - 
findDependentPoliciespublic List<Policy> findDependentPolicies(ResourceServer resourceServer, String policyId) Description copied from interface:PolicyStoreReturns a list ofPolicythat depends on another policy with the givenid.- Specified by:
- findDependentPoliciesin interface- PolicyStore
- Parameters:
- resourceServer- the resource server
- policyId- the id of the policy to query its dependents
- Returns:
- a list of policies that depends on the a policy with the given identifier
 
 
- 
 
-