org.keycloak.authorization.store

## Interface PolicyStore

- All Known Implementing Classes:
    JPAPolicyStore, StoreFactoryCacheSession.PolicyCache

      public interface PolicyStore

  A `PolicyStore` is responsible to manage the persistence of `Policy` instances.
  Author:
    Pedro Igor

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Policy` | `create(AbstractPolicyRepresentation representation, ResourceServer resourceServer)` Creates a new `Policy` instance.
    `void` | `delete(String id)` Deletes a policy from the underlying persistence mechanism.
    `Policy` | `findById(String id, String resourceServerId)` Returns a `Policy` with the given `id`
    `Policy` | `findByName(String name, String resourceServerId)` Returns a `Policy` with the given `name`
    `List<Policy>` | `findByResource(String resourceId, String resourceServerId)` Returns a list of `Policy` associated with a `org.keycloak.authorization.core.model.Resource` with the given `resourceId`.
    `void` | `findByResource(String resourceId, String resourceServerId, Consumer<Policy> consumer)`
    `List<Policy>` | `findByResourceServer(Map<String,String[]> attributes, String resourceServerId, int firstResult, int maxResult)` Returns a list of `Policy` associated with a `ResourceServer` with the given `resourceServerId`.
    `List<Policy>` | `findByResourceServer(String resourceServerId)` Returns a list of `Policy` associated with a `ResourceServer` with the given `resourceServerId`.
    `List<Policy>` | `findByResourceType(String resourceType, String resourceServerId)` Returns a list of `Policy` associated with a `org.keycloak.authorization.core.model.Resource` with the given `type`.
    `void` | `findByResourceType(String type, String id, Consumer<Policy> policyConsumer)`
    `List<Policy>` | `findByScopeIds(List<String> scopeIds, String resourceServerId)` Returns a list of `Policy` associated with a `org.keycloak.authorization.core.model.Scope` with the given `scopeIds`.
    `List<Policy>` | `findByScopeIds(List<String> scopeIds, String resourceId, String resourceServerId)` Returns a list of `Policy` associated with a `org.keycloak.authorization.core.model.Scope` with the given `resourceId` and `scopeIds`.
    `void` | `findByScopeIds(List<String> scopeIds, String resourceId, String resourceServerId, Consumer<Policy> consumer)`
    `List<Policy>` | `findByType(String type, String resourceServerId)` Returns a list of `Policy` with the given `type`.
    `List<Policy>` | `findDependentPolicies(String id, String resourceServerId)` Returns a list of `Policy` that depends on another policy with the given `id`.

- - ### Method Detail

    - #### create

          Policy create(AbstractPolicyRepresentation representation,
                        ResourceServer resourceServer)

      Creates a new `Policy` instance. 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 representation
        `resourceServer` - 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 a `Policy` with the given `id`
      Parameters:
        `id` - the identifier of the policy
        `resourceServerId` - the resource server id
      Returns:
        a policy with the given identifier.

    - #### findByName

          Policy findByName(String name,
                            String resourceServerId)

      Returns a `Policy` with the given `name`
      Parameters:
        `name` - the name of the policy
        `resourceServerId` - the resource server id
      Returns:
        a policy with the given name.

    - #### findByResourceServer

          List<Policy> findByResourceServer(String resourceServerId)

      Returns a list of `Policy` associated with a `ResourceServer` with the given `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<String,String[]> attributes,
                                            String resourceServerId,
                                            int firstResult,
                                            int maxResult)

      Returns a list of `Policy` associated with a `ResourceServer` with the given `resourceServerId`.
      Parameters:
        `attributes` - a map holding the attributes that will be used as a filter
        `resourceServerId` - the identifier of a resource server
      Returns:
        a list of policies that belong to the given resource server

    - #### findByResource

          List<Policy> findByResource(String resourceId,
                                      String resourceServerId)

      Returns a list of `Policy` associated with a `org.keycloak.authorization.core.model.Resource` with the given `resourceId`.
      Parameters:
        `resourceId` - the identifier of a resource
        `resourceServerId` - 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

          List<Policy> findByResourceType(String resourceType,
                                          String resourceServerId)

      Returns a list of `Policy` associated with a `org.keycloak.authorization.core.model.Resource` with the given `type`.
      Parameters:
        `resourceType` - the type of a resource
        `resourceServerId` - 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 of `Policy` associated with a `org.keycloak.authorization.core.model.Scope` with the given `scopeIds`.
      Parameters:
        `scopeIds` - the id of the scopes
        `resourceServerId` - the resource server id
      Returns:
        a list of policies associated with the given scopes

    - #### findByScopeIds

          List<Policy> findByScopeIds(List<String> scopeIds,
                                      String resourceId,
                                      String resourceServerId)

      Returns a list of `Policy` associated with a `org.keycloak.authorization.core.model.Scope` with the given `resourceId` and `scopeIds`.
      Parameters:
        `scopeIds` - the id of the scopes
        `resourceId` - the id of the resource
        `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)

    - #### findByType

          List<Policy> findByType(String type,
                                  String resourceServerId)

      Returns a list of `Policy` with the given `type`.
      Parameters:
        `type` - the type of the policy
        `resourceServerId` - the resource server id
      Returns:
        a list of policies with the given type

    - #### findDependentPolicies

          List<Policy> findDependentPolicies(String id,
                                             String resourceServerId)

      Returns a list of `Policy` that depends on another policy with the given `id`.
      Parameters:
        `id` - the id of the policy to query its dependents
        `resourceServerId` - the resource server id
      Returns:
        a list of policies that depends on the a policy with the given identifier

    - #### findByResourceType

          void findByResourceType(String type,
                                  String id,
                                  Consumer<Policy> policyConsumer)

Copyright © 2021 JBoss by Red Hat. All rights reserved.