Package org.keycloak.authorization.store
Interface PolicyStore
-
public interface PolicyStoreAPolicyStoreis responsible to manage the persistence ofPolicyinstances.- Author:
- Pedro Igor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Policycreate(AbstractPolicyRepresentation representation, ResourceServer resourceServer)Creates a newPolicyinstance.voiddelete(String id)Deletes a policy from the underlying persistence mechanism.PolicyfindById(String id, String resourceServerId)Returns aPolicywith the givenidPolicyfindByName(String name, String resourceServerId)Returns aPolicywith the givennamedefault List<Policy>findByResource(String resourceId, String resourceServerId)Returns a list ofPolicyassociated with aorg.keycloak.authorization.core.model.Resourcewith the givenresourceId.voidfindByResource(String resourceId, String resourceServerId, Consumer<Policy> consumer)List<Policy>findByResourceServer(String resourceServerId)List<Policy>findByResourceServer(Map<Policy.FilterOption,String[]> attributes, String resourceServerId, int firstResult, int maxResult)default List<Policy>findByResourceType(String resourceType, String resourceServerId)Returns a list ofPolicyassociated with aorg.keycloak.authorization.core.model.Resourcewith the giventype.voidfindByResourceType(String type, String resourceServerId, Consumer<Policy> policyConsumer)List<Policy>findByScopeIds(List<String> scopeIds, String resourceServerId)Returns a list ofPolicyassociated with aorg.keycloak.authorization.core.model.Scopewith the givenscopeIds.default List<Policy>findByScopeIds(List<String> scopeIds, String resourceId, String resourceServerId)Returns a list ofPolicyassociated with aorg.keycloak.authorization.core.model.Scopewith the givenresourceIdandscopeIds.voidfindByScopeIds(List<String> scopeIds, String resourceId, String resourceServerId, Consumer<Policy> consumer)Effectively the same method asfindByScopeIds(List, String, String), however in the end theconsumeris fed with the result.List<Policy>findByType(String type, String resourceServerId)Returns a list ofPolicywith the giventype.List<Policy>findDependentPolicies(String id, String resourceServerId)Returns a list ofPolicythat depends on another policy with the givenid.
-
-
-
Method Detail
-
create
Policy create(AbstractPolicyRepresentation representation, ResourceServer resourceServer)
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:
representation- the policy representationresourceServer- the resource server to which this policy belongs- Returns:
- a new instance of
Policy
-
delete
void delete(String id)
Deletes a policy from the underlying persistence mechanism.- Parameters:
id- the id of the policy to delete
-
findById
Policy findById(String id, String resourceServerId)
Returns aPolicywith the givenid- Parameters:
id- the identifier of the policyresourceServerId- the resource server id- Returns:
- a policy with the given identifier.
-
findByName
Policy findByName(String name, String resourceServerId)
Returns aPolicywith the givenname- Parameters:
name- the name of the policyresourceServerId- the resource server id- Returns:
- a policy with the given name.
-
findByResourceServer
List<Policy> findByResourceServer(String resourceServerId)
- Parameters:
resourceServerId- the identifier of a resource server- Returns:
- a list of policies that belong to the given resource server
-
findByResourceServer
List<Policy> findByResourceServer(Map<Policy.FilterOption,String[]> attributes, String resourceServerId, int firstResult, int maxResult)
- Parameters:
attributes- a map holding the attributes that will be used as a filter; possible filter options are given byPolicy.FilterOptionresourceServerId- the identifier of a resource server- Returns:
- a list of policies that belong to the given resource server
- Throws:
IllegalArgumentException- when there is an unknown attribute in theattributesmap
-
findByResource
default List<Policy> findByResource(String resourceId, String resourceServerId)
Returns a list ofPolicyassociated with aorg.keycloak.authorization.core.model.Resourcewith the givenresourceId.- Parameters:
resourceId- the identifier of a resourceresourceServerId- the resource server id- Returns:
- a list of policies associated with the given resource
-
findByResource
void findByResource(String resourceId, String resourceServerId, Consumer<Policy> consumer)
-
findByResourceType
default List<Policy> findByResourceType(String resourceType, String resourceServerId)
Returns a list ofPolicyassociated with aorg.keycloak.authorization.core.model.Resourcewith the giventype.- Parameters:
resourceType- the type of a resourceresourceServerId- the resource server id- Returns:
- a list of policies associated with the given resource type
-
findByScopeIds
List<Policy> findByScopeIds(List<String> scopeIds, String resourceServerId)
Returns a list ofPolicyassociated with aorg.keycloak.authorization.core.model.Scopewith the givenscopeIds.- Parameters:
scopeIds- the id of the scopesresourceServerId- the resource server id- Returns:
- a list of policies associated with the given scopes
-
findByScopeIds
default List<Policy> findByScopeIds(List<String> scopeIds, String resourceId, String resourceServerId)
Returns a list ofPolicyassociated with aorg.keycloak.authorization.core.model.Scopewith the givenresourceIdandscopeIds.- Parameters:
scopeIds- the id of the scopesresourceId- the id of the resource. Ignored ifnull.resourceServerId- the resource server id- Returns:
- a list of policies associated with the given scopes
-
findByScopeIds
void findByScopeIds(List<String> scopeIds, String resourceId, String resourceServerId, Consumer<Policy> consumer)
Effectively the same method asfindByScopeIds(List, String, String), however in the end theconsumeris fed with the result.
-
findByType
List<Policy> findByType(String type, String resourceServerId)
Returns a list ofPolicywith the giventype.- Parameters:
type- the type of the policyresourceServerId- the resource server id- Returns:
- a list of policies with the given type
-
findDependentPolicies
List<Policy> findDependentPolicies(String id, String resourceServerId)
Returns a list ofPolicythat depends on another policy with the givenid.- Parameters:
id- the id of the policy to query its dependentsresourceServerId- the resource server id- Returns:
- a list of policies that depends on the a policy with the given identifier
-
-