Package org.keycloak.authorization.store
Interface PolicyStore
- 
- All Known Implementing Classes:
- JPAPolicyStore,- MapPolicyStore,- StoreFactoryCacheSession.PolicyCache
 
 public interface PolicyStoreAPolicyStoreis responsible to manage the persistence ofPolicyinstances.- Author:
- Pedro Igor
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default 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 givennamedefault List<Policy>findByResource(ResourceServer resourceServer, Resource resource)voidfindByResource(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 theResourceServerdefault List<Policy>findByResourceType(ResourceServer resourceServer, String resourceType)voidfindByResourceType(ResourceServer resourceServer, String type, Consumer<Policy> policyConsumer)Searches for policies associated with aResourceServerand passes the result to the consumerList<Policy>findByScopes(ResourceServer resourceServer, List<Scope> scopes)default List<Policy>findByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes)voidfindByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes, Consumer<Policy> consumer)Effectively the same method asfindByScopes(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 id)Returns a list ofPolicythat depends on another policy with the givenid.
 
- 
- 
- 
Method Detail- 
createPolicy create(ResourceServer resourceServer, AbstractPolicyRepresentation representation) Creates a newPolicyinstance. The new instance is not necessarily persisted though, which may require a call to the {#save} method to actually make it persistent.- Parameters:
- resourceServer- the resource server to which this policy belongs. Cannot be- null.
- representation- the policy representation
- Returns:
- a new instance of Policy
 
 - 
deletevoid delete(RealmModel realm, String id) Deletes a policy from the underlying persistence mechanism.- Parameters:
- realm- the realm that the removed policy belongs to. Cannot be- null
- id- the id of the policy to delete
 
 - 
findByIdPolicy findById(RealmModel realm, ResourceServer resourceServer, String id) Returns aPolicywith the givenid- 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.
 
 - 
findByNamePolicy findByName(ResourceServer resourceServer, String name) Returns aPolicywith the givenname- 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.
 
 - 
findByResourceServerList<Policy> findByResourceServer(ResourceServer resourceServer) Returns a list ofPolicyassociated with theResourceServer- Parameters:
- resourceServer- the resource server. Cannot be- null.
- Returns:
- a list of policies that belong to the given resource server
 
 - 
findList<Policy> find(RealmModel realm, ResourceServer resourceServer, Map<Policy.FilterOption,String[]> attributes, Integer firstResult, Integer maxResults) - 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
- Throws:
- IllegalArgumentException- when there is an unknown attribute in the- attributesmap
 
 - 
findByResourcedefault List<Policy> findByResource(ResourceServer resourceServer, Resource resource) - Parameters:
- resourceServer- the resource server. Cannot be- null.
- resource- the resource. Cannot be- null.
- Returns:
- a list of policies associated with the given resource
 
 - 
findByResourcevoid findByResource(ResourceServer resourceServer, Resource resource, Consumer<Policy> consumer) Searches for all policies associated with theResourceand passes the result to theconsumer- Parameters:
- resourceServer- the resourceServer. Cannot be- null.
- resource- the resource. Cannot be- null.
- consumer- consumer of policies resulted from the search
 
 - 
findByResourceTypedefault List<Policy> findByResourceType(ResourceServer resourceServer, String resourceType) - Parameters:
- resourceServer- the resource server id. Cannot be- null.
- resourceType- the type of a resource
- Returns:
- a list of policies associated with the given resource type
 
 - 
findByResourceTypevoid findByResourceType(ResourceServer resourceServer, String type, Consumer<Policy> policyConsumer) Searches for policies associated with aResourceServerand passes the result to the consumer- Parameters:
- resourceServer- the resourceServer. Cannot be- null.
- type- the type of a resource
- policyConsumer- consumer of policies resulted from the search
 
 - 
findByScopesList<Policy> findByScopes(ResourceServer resourceServer, List<Scope> scopes) - Parameters:
- resourceServer- the resource server. Cannot be- null.
- scopes- the scopes
- Returns:
- a list of policies associated with the given scopes
 
 - 
findByScopesdefault List<Policy> findByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes) - Parameters:
- resourceServer- the resource server. Cannot be- null.
- resource- the resource. Ignored if- null.
- scopes- the scopes
- Returns:
- a list of policies associated with the given scopes
 
 - 
findByScopesvoid findByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes, Consumer<Policy> consumer) Effectively the same method asfindByScopes(ResourceServer, Resource, List), however in the end theconsumeris fed with the result.
 - 
findByTypeList<Policy> findByType(ResourceServer resourceServer, String type) Returns a list ofPolicywith the giventype.- Parameters:
- resourceServer- the resource server id. Cannot be- null.
- type- the type of the policy
- Returns:
- a list of policies with the given type
 
 - 
findDependentPoliciesList<Policy> findDependentPolicies(ResourceServer resourceServer, String id) Returns a list ofPolicythat depends on another policy with the givenid.- Parameters:
- resourceServer- the resource server
- id- the id of the policy to query its dependents
- Returns:
- a list of policies that depends on the a policy with the given identifier
 
 
- 
 
-