Class MapPolicyStore
- java.lang.Object
-
- org.keycloak.models.map.authorization.MapPolicyStore
-
- All Implemented Interfaces:
PolicyStore
public class MapPolicyStore extends Object implements PolicyStore
-
-
Constructor Summary
Constructors Constructor Description MapPolicyStore(KeycloakSession session, MapStorage<MapPolicyEntity,Policy> policyStore, AuthorizationProvider provider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Policy
create(ResourceServer resourceServer, AbstractPolicyRepresentation representation)
Creates a newPolicy
instance.void
delete(String id)
Deletes a policy from the underlying persistence mechanism.Policy
findById(ResourceServer resourceServer, String id)
Returns aPolicy
with the givenid
Policy
findByName(ResourceServer resourceServer, String name)
Returns aPolicy
with the givenname
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)
List<Policy>
findByResourceServer(ResourceServer resourceServer, Map<Policy.FilterOption,String[]> attributes, Integer firstResult, Integer maxResults)
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)
void
findByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes, Consumer<Policy> consumer)
Effectively the same method asPolicyStore.findByScopes(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
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.keycloak.authorization.store.PolicyStore
findByResource, findByResourceType, findByScopes
-
-
-
-
Constructor Detail
-
MapPolicyStore
public MapPolicyStore(KeycloakSession session, MapStorage<MapPolicyEntity,Policy> policyStore, AuthorizationProvider provider)
-
-
Method Detail
-
create
public Policy create(ResourceServer resourceServer, AbstractPolicyRepresentation representation)
Description copied from interface:PolicyStore
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.- Specified by:
create
in interfacePolicyStore
- Parameters:
resourceServer
- the resource server to which this policy belongsrepresentation
- the policy representation- Returns:
- a new instance of
Policy
-
delete
public void delete(String id)
Description copied from interface:PolicyStore
Deletes a policy from the underlying persistence mechanism.- Specified by:
delete
in interfacePolicyStore
- Parameters:
id
- the id of the policy to delete
-
findById
public Policy findById(ResourceServer resourceServer, String id)
Description copied from interface:PolicyStore
Returns aPolicy
with the givenid
- Specified by:
findById
in interfacePolicyStore
- Parameters:
resourceServer
- the resource serverid
- the identifier of the policy- Returns:
- a policy with the given identifier.
-
findByName
public Policy findByName(ResourceServer resourceServer, String name)
Description copied from interface:PolicyStore
Returns aPolicy
with the givenname
- Specified by:
findByName
in interfacePolicyStore
- Parameters:
resourceServer
- the resource servername
- the name of the policy- Returns:
- a policy with the given name.
-
findByResourceServer
public List<Policy> findByResourceServer(ResourceServer resourceServer)
Description copied from interface:PolicyStore
- Specified by:
findByResourceServer
in interfacePolicyStore
- Parameters:
resourceServer
- the identifier of a resource server- Returns:
- a list of policies that belong to the given resource server
-
findByResourceServer
public List<Policy> findByResourceServer(ResourceServer resourceServer, Map<Policy.FilterOption,String[]> attributes, Integer firstResult, Integer maxResults)
Description copied from interface:PolicyStore
- Specified by:
findByResourceServer
in interfacePolicyStore
- Parameters:
resourceServer
- the identifier of a resource serverattributes
- 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
-
findByResource
public void findByResource(ResourceServer resourceServer, Resource resource, Consumer<Policy> consumer)
Description copied from interface:PolicyStore
Searches for all policies associated with theResource
and passes the result to theconsumer
- Specified by:
findByResource
in interfacePolicyStore
- Parameters:
resourceServer
- the resourceServerresource
- the resourceconsumer
- consumer of policies resulted from the search
-
findByResourceType
public void findByResourceType(ResourceServer resourceServer, String type, Consumer<Policy> policyConsumer)
Description copied from interface:PolicyStore
Searches for policies associated with aResourceServer
and passes the result to the consumer- Specified by:
findByResourceType
in interfacePolicyStore
- Parameters:
resourceServer
- the resourceServertype
- the type of a resourcepolicyConsumer
- consumer of policies resulted from the search
-
findByScopes
public List<Policy> findByScopes(ResourceServer resourceServer, List<Scope> scopes)
Description copied from interface:PolicyStore
- Specified by:
findByScopes
in interfacePolicyStore
- Parameters:
resourceServer
- the resource serverscopes
- the scopes- Returns:
- a list of policies associated with the given scopes
-
findByScopes
public void findByScopes(ResourceServer resourceServer, Resource resource, List<Scope> scopes, Consumer<Policy> consumer)
Description copied from interface:PolicyStore
Effectively the same method asPolicyStore.findByScopes(ResourceServer, Resource, List)
, however in the end theconsumer
is fed with the result.- Specified by:
findByScopes
in interfacePolicyStore
-
findByType
public List<Policy> findByType(ResourceServer resourceServer, String type)
Description copied from interface:PolicyStore
Returns a list ofPolicy
with the giventype
.- Specified by:
findByType
in interfacePolicyStore
- Parameters:
resourceServer
- the resource server idtype
- the type of the policy- Returns:
- a list of policies with the given type
-
findDependentPolicies
public List<Policy> findDependentPolicies(ResourceServer resourceServer, String id)
Description copied from interface:PolicyStore
Returns a list ofPolicy
that depends on another policy with the givenid
.- Specified by:
findDependentPolicies
in interfacePolicyStore
- 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
-
-