Package org.keycloak.authorization.store
Interface PolicyStore
-
- All Known Implementing Classes:
JPAPolicyStore
,MapPolicyStore
,StoreFactoryCacheSession.PolicyCache
public interface PolicyStore
APolicyStore
is responsible to manage the persistence ofPolicy
instances.- Author:
- Pedro Igor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Policy
create(ResourceServer resourceServer, AbstractPolicyRepresentation representation)
Creates a newPolicy
instance.void
delete(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)
Policy
findById(RealmModel realm, ResourceServer resourceServer, String id)
Returns aPolicy
with the givenid
Policy
findByName(ResourceServer resourceServer, String name)
Returns aPolicy
with the givenname
default List<Policy>
findByResource(ResourceServer resourceServer, Resource resource)
void
findByResource(ResourceServer resourceServer, Resource resource, Consumer<Policy> consumer)
Searches for all policies associated with theResource
and passes the result to theconsumer
List<Policy>
findByResourceServer(ResourceServer resourceServer)
Returns a list ofPolicy
associated with theResourceServer
default List<Policy>
findByResourceType(ResourceServer resourceServer, String resourceType)
void
findByResourceType(ResourceServer resourceServer, String type, Consumer<Policy> policyConsumer)
Searches for policies associated with aResourceServer
and passes the result to the consumerList<Policy>
findByScopes(ResourceServer resourceServer, List<Scope> scopes)
default List<Policy>
findByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes)
void
findByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes, Consumer<Policy> consumer)
Effectively the same method asfindByScopes(ResourceServer, Resource, List)
, however in the end theconsumer
is fed with the result.List<Policy>
findByType(ResourceServer resourceServer, String type)
Returns a list ofPolicy
with the giventype
.List<Policy>
findDependentPolicies(ResourceServer resourceServer, String id)
Returns a list ofPolicy
that depends on another policy with the givenid
.
-
-
-
Method Detail
-
create
Policy create(ResourceServer resourceServer, AbstractPolicyRepresentation representation)
Creates a newPolicy
instance. 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 benull
.representation
- the policy representation- Returns:
- a new instance of
Policy
-
delete
void delete(RealmModel realm, String id)
Deletes a policy from the underlying persistence mechanism.- Parameters:
realm
- the realm that the removed policy belongs to. Cannot benull
id
- the id of the policy to delete
-
findById
Policy findById(RealmModel realm, ResourceServer resourceServer, String id)
Returns aPolicy
with the givenid
- Parameters:
realm
- the realm. Cannot benull
.resourceServer
- the resource server. Ignored ifnull
.id
- the identifier of the policy- Returns:
- a policy with the given identifier.
-
findByName
Policy findByName(ResourceServer resourceServer, String name)
Returns aPolicy
with the givenname
- Parameters:
resourceServer
- the resource server. Cannot benull
name
- the name of the policy- Returns:
- a policy with the given name or
null
if no such policy exists.
-
findByResourceServer
List<Policy> findByResourceServer(ResourceServer resourceServer)
Returns a list ofPolicy
associated with theResourceServer
- Parameters:
resourceServer
- the resource server. Cannot benull
.- Returns:
- a list of policies that belong to the given resource server
-
find
List<Policy> find(RealmModel realm, ResourceServer resourceServer, Map<Policy.FilterOption,String[]> attributes, Integer firstResult, Integer maxResults)
- Parameters:
realm
- the realm. Cannot benull
.resourceServer
- the identifier of a resource server. Ignored ifnull
.attributes
- a map holding the attributes that will be used as a filter; possible filter options are given byPolicy.FilterOption
firstResult
- first result to return. Ignored if negative ornull
.maxResults
- maximum number of results to return. Ignored if negative ornull
.- Returns:
- a list of policies that belong to the given resource server
- Throws:
IllegalArgumentException
- when there is an unknown attribute in theattributes
map
-
findByResource
default List<Policy> findByResource(ResourceServer resourceServer, Resource resource)
- Parameters:
resourceServer
- the resource server. Cannot benull
.resource
- the resource. Cannot benull
.- Returns:
- a list of policies associated with the given resource
-
findByResource
void findByResource(ResourceServer resourceServer, Resource resource, Consumer<Policy> consumer)
Searches for all policies associated with theResource
and passes the result to theconsumer
- Parameters:
resourceServer
- the resourceServer. Cannot benull
.resource
- the resource. Cannot benull
.consumer
- consumer of policies resulted from the search
-
findByResourceType
default List<Policy> findByResourceType(ResourceServer resourceServer, String resourceType)
- Parameters:
resourceServer
- the resource server id. Cannot benull
.resourceType
- the type of a resource- Returns:
- a list of policies associated with the given resource type
-
findByResourceType
void findByResourceType(ResourceServer resourceServer, String type, Consumer<Policy> policyConsumer)
Searches for policies associated with aResourceServer
and passes the result to the consumer- Parameters:
resourceServer
- the resourceServer. Cannot benull
.type
- the type of a resourcepolicyConsumer
- consumer of policies resulted from the search
-
findByScopes
List<Policy> findByScopes(ResourceServer resourceServer, List<Scope> scopes)
- Parameters:
resourceServer
- the resource server. Cannot benull
.scopes
- the scopes- Returns:
- a list of policies associated with the given scopes
-
findByScopes
default List<Policy> findByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes)
- Parameters:
resourceServer
- the resource server. Cannot benull
.resource
- the resource. Ignored ifnull
.scopes
- the scopes- Returns:
- a list of policies associated with the given scopes
-
findByScopes
void findByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes, Consumer<Policy> consumer)
Effectively the same method asfindByScopes(ResourceServer, Resource, List)
, however in the end theconsumer
is fed with the result.
-
findByType
List<Policy> findByType(ResourceServer resourceServer, String type)
Returns a list ofPolicy
with the giventype
.- Parameters:
resourceServer
- the resource server id. Cannot benull
.type
- the type of the policy- Returns:
- a list of policies with the given type
-
findDependentPolicies
List<Policy> findDependentPolicies(ResourceServer resourceServer, String id)
Returns a list ofPolicy
that depends on another policy with the givenid
.- Parameters:
resourceServer
- the resource serverid
- the id of the policy to query its dependents- Returns:
- a list of policies that depends on the a policy with the given identifier
-
-