org.keycloak.authorization.jpa.store

## Class JPAPolicyStore

- java.lang.Object
- - org.keycloak.authorization.jpa.store.JPAPolicyStore

- All Implemented Interfaces:
    PolicyStore

      public class JPAPolicyStore
      extends Object
      implements PolicyStore

  Author:
    Pedro Igor

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JPAPolicyStore(javax.persistence.EntityManager entityManager, AuthorizationProvider provider)`

  - ### Method Summary

    All Methods Instance Methods Concrete 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`
    `void` | `findByResource(String resourceId, String resourceServerId, Consumer<Policy> consumer)`
    `List<Policy>` | `findByResourceServer(Map<Policy.FilterOption,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`.
    `void` | `findByResourceType(String resourceType, String resourceServerId, Consumer<Policy> consumer)`
    `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`.
    `void` | `findByScopeIds(List<String> scopeIds, String resourceId, String resourceServerId, Consumer<Policy> consumer)` Effectively the same method as `PolicyStore.findByScopeIds(List, String, String)`, however in the end the `consumer` is fed with the result.
    `List<Policy>` | `findByType(String type, String resourceServerId)` Returns a list of `Policy` with the given `type`.
    `List<Policy>` | `findDependentPolicies(String policyId, String resourceServerId)` Returns a list of `Policy` that depends on another policy with the given `id`.

    - ### 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, findByScopeIds`

- - ### Constructor Detail

    - #### JPAPolicyStore

          public JPAPolicyStore(javax.persistence.EntityManager entityManager,
                                AuthorizationProvider provider)

  - ### Method Detail

    - #### create

          public Policy create(AbstractPolicyRepresentation representation,
                               ResourceServer resourceServer)

      Description copied from interface: `PolicyStore`
      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.
      Specified by:
        `create` in interface `PolicyStore`
      Parameters:
        `representation` - the policy representation
        `resourceServer` - the resource server to which this policy belongs
      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 interface `PolicyStore`
      Parameters:
        `id` - the id of the policy to delete

    - #### findById

          public Policy findById(String id,
                                 String resourceServerId)

      Description copied from interface: `PolicyStore`
      Returns a `Policy` with the given `id`
      Specified by:
        `findById` in interface `PolicyStore`
      Parameters:
        `id` - the identifier of the policy
        `resourceServerId` - the resource server id
      Returns:
        a policy with the given identifier.

    - #### findByName

          public Policy findByName(String name,
                                   String resourceServerId)

      Description copied from interface: `PolicyStore`
      Returns a `Policy` with the given `name`
      Specified by:
        `findByName` in interface `PolicyStore`
      Parameters:
        `name` - the name of the policy
        `resourceServerId` - the resource server id
      Returns:
        a policy with the given name.

    - #### findByResourceServer

          public List<Policy> findByResourceServer(String resourceServerId)

      Description copied from interface: `PolicyStore`
      Returns a list of `Policy` associated with a `ResourceServer` with the given `resourceServerId`.
      Specified by:
        `findByResourceServer` in interface `PolicyStore`
      Parameters:
        `resourceServerId` - the identifier of a resource server
      Returns:
        a list of policies that belong to the given resource server

    - #### findByResourceServer

          public List<Policy> findByResourceServer(Map<Policy.FilterOption,String[]> attributes,
                                                   String resourceServerId,
                                                   int firstResult,
                                                   int maxResult)

      Description copied from interface: `PolicyStore`
      Returns a list of `Policy` associated with a `ResourceServer` with the given `resourceServerId`.
      Specified by:
        `findByResourceServer` in interface `PolicyStore`
      Parameters:
        `attributes` - a map holding the attributes that will be used as a filter; possible filter options are given by `Policy.FilterOption`
        `resourceServerId` - the identifier of a resource server
      Returns:
        a list of policies that belong to the given resource server

    - #### findByResource

          public void findByResource(String resourceId,
                                     String resourceServerId,
                                     Consumer<Policy> consumer)

      Specified by:
        `findByResource` in interface `PolicyStore`

    - #### findByResourceType

          public void findByResourceType(String resourceType,
                                         String resourceServerId,
                                         Consumer<Policy> consumer)

      Specified by:
        `findByResourceType` in interface `PolicyStore`

    - #### findByScopeIds

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

      Description copied from interface: `PolicyStore`
      Returns a list of `Policy` associated with a `org.keycloak.authorization.core.model.Scope` with the given `scopeIds`.
      Specified by:
        `findByScopeIds` in interface `PolicyStore`
      Parameters:
        `scopeIds` - the id of the scopes
        `resourceServerId` - the resource server id
      Returns:
        a list of policies associated with the given scopes

    - #### findByScopeIds

          public void findByScopeIds(List<String> scopeIds,
                                     String resourceId,
                                     String resourceServerId,
                                     Consumer<Policy> consumer)

      Description copied from interface: `PolicyStore`
      Effectively the same method as `PolicyStore.findByScopeIds(List, String, String)`, however in the end the `consumer` is fed with the result.
      Specified by:
        `findByScopeIds` in interface `PolicyStore`

    - #### findByType

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

      Description copied from interface: `PolicyStore`
      Returns a list of `Policy` with the given `type`.
      Specified by:
        `findByType` in interface `PolicyStore`
      Parameters:
        `type` - the type of the policy
        `resourceServerId` - the resource server id
      Returns:
        a list of policies with the given type

    - #### findDependentPolicies

          public List<Policy> findDependentPolicies(String policyId,
                                                    String resourceServerId)

      Description copied from interface: `PolicyStore`
      Returns a list of `Policy` that depends on another policy with the given `id`.
      Specified by:
        `findDependentPolicies` in interface `PolicyStore`
      Parameters:
        `policyId` - 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

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