org.keycloak.authorization.jpa.store

## Class JPAResourceStore

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

- All Implemented Interfaces:
    ResourceStore

      public class JPAResourceStore
      extends Object
      implements ResourceStore

  Author:
    Pedro Igor

- - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Resource` | `create(String id, String name, ResourceServer resourceServer, String owner)` Creates a `Resource` instance backed by this persistent storage implementation.
    `void` | `delete(String id)` Removes a `Resource` instance, with the given `id` from the persistent storage.
    `Resource` | `findById(String id, String resourceServerId)` Returns a `Resource` instance based on its identifier.
    `Resource` | `findByName(String name, String resourceServerId)` Find a `Resource` by its name where the owner is the resource server itself.
    `Resource` | `findByName(String name, String ownerId, String resourceServerId)` Find a `Resource` by its name where the owner is the given `ownerId`.
    `void` | `findByOwner(String ownerId, String resourceServerId, Consumer<Resource> consumer)`
    `List<Resource>` | `findByOwner(String ownerId, String resourceServerId, int first, int max)`
    `List<Resource>` | `findByResourceServer(Map<Resource.FilterOption,String[]> attributes, String resourceServerId, int firstResult, int maxResult)` Finds all `Resource` instances associated with a given resource server.
    `List<Resource>` | `findByResourceServer(String resourceServerId)` Finds all `Resource` instances associated with a given resource server.
    `void` | `findByScope(List<String> scopes, String resourceServerId, Consumer<Resource> consumer)`
    `void` | `findByType(String type, String resourceServerId, Consumer<Resource> consumer)` Finds all `Resource` with the given type.
    `void` | `findByType(String type, String owner, String resourceServerId, Consumer<Resource> consumer)` Finds all `Resource` with the given type.
    `void` | `findByTypeInstance(String type, String resourceServerId, Consumer<Resource> consumer)`
    `List<Resource>` | `findByUri(String uri, String resourceServerId)` Finds all `Resource` instances with the given uri.

    - ### 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.ResourceStore

      `create, findByOwner, findByScope, findByType, findByType, findByTypeInstance`

- - ### Constructor Detail

    - #### JPAResourceStore

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

  - ### Method Detail

    - #### create

          public Resource create(String id,
                                 String name,
                                 ResourceServer resourceServer,
                                 String owner)

      Description copied from interface: `ResourceStore`

      Creates a `Resource` instance backed by this persistent storage implementation.

      Specified by:
        `create` in interface `ResourceStore`
      Parameters:
        `id` - the id of this resource. It must be unique. Will be randomly generated if null.
        `name` - the name of this resource. It must be unique.
        `resourceServer` - the resource server to where the given resource belongs to
        `owner` - the owner of this resource or null if the resource server is the owner
      Returns:
        an instance backed by the underlying storage implementation

    - #### delete

          public void delete(String id)

      Description copied from interface: `ResourceStore`
      Removes a `Resource` instance, with the given `id` from the persistent storage.
      Specified by:
        `delete` in interface `ResourceStore`
      Parameters:
        `id` - the identifier of an existing resource instance

    - #### findById

          public Resource findById(String id,
                                   String resourceServerId)

      Description copied from interface: `ResourceStore`
      Returns a `Resource` instance based on its identifier.
      Specified by:
        `findById` in interface `ResourceStore`
      Parameters:
        `id` - the identifier of an existing resource instance
      Returns:
        the resource instance with the given identifier or null if no instance was found

    - #### findByOwner

          public void findByOwner(String ownerId,
                                  String resourceServerId,
                                  Consumer<Resource> consumer)

      Specified by:
        `findByOwner` in interface `ResourceStore`

    - #### findByOwner

          public List<Resource> findByOwner(String ownerId,
                                            String resourceServerId,
                                            int first,
                                            int max)

      Specified by:
        `findByOwner` in interface `ResourceStore`

    - #### findByUri

          public List<Resource> findByUri(String uri,
                                          String resourceServerId)

      Description copied from interface: `ResourceStore`
      Finds all `Resource` instances with the given uri.
      Specified by:
        `findByUri` in interface `ResourceStore`
      Parameters:
        `uri` - the identifier of the uri
      Returns:
        a list with all resource instances owned by the given owner

    - #### findByResourceServer

          public List<Resource> findByResourceServer(String resourceServerId)

      Description copied from interface: `ResourceStore`
      Finds all `Resource` instances associated with a given resource server.
      Specified by:
        `findByResourceServer` in interface `ResourceStore`
      Parameters:
        `resourceServerId` - the identifier of the resource server
      Returns:
        a list with all resources associated with the given resource server

    - #### findByResourceServer

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

      Description copied from interface: `ResourceStore`
      Finds all `Resource` instances associated with a given resource server.
      Specified by:
        `findByResourceServer` in interface `ResourceStore`
      Parameters:
        `attributes` - a map holding the attributes that will be used as a filter; possible filter options are given by `Resource.FilterOption`
        `resourceServerId` - the identifier of the resource server
      Returns:
        a list with all resources associated with the given resource server

    - #### findByScope

          public void findByScope(List<String> scopes,
                                  String resourceServerId,
                                  Consumer<Resource> consumer)

      Specified by:
        `findByScope` in interface `ResourceStore`

    - #### findByName

          public Resource findByName(String name,
                                     String resourceServerId)

      Description copied from interface: `ResourceStore`
      Find a `Resource` by its name where the owner is the resource server itself.
      Specified by:
        `findByName` in interface `ResourceStore`
      Parameters:
        `name` - the name of the resource
        `resourceServerId` - the identifier of the resource server
      Returns:
        a resource with the given name

    - #### findByName

          public Resource findByName(String name,
                                     String ownerId,
                                     String resourceServerId)

      Description copied from interface: `ResourceStore`
      Find a `Resource` by its name where the owner is the given `ownerId`.
      Specified by:
        `findByName` in interface `ResourceStore`
      Parameters:
        `name` - the name of the resource
        `ownerId` - the owner id
        `resourceServerId` - the identifier of the resource server
      Returns:
        a resource with the given name

    - #### findByType

          public void findByType(String type,
                                 String resourceServerId,
                                 Consumer<Resource> consumer)

      Description copied from interface: `ResourceStore`
      Finds all `Resource` with the given type.
      Specified by:
        `findByType` in interface `ResourceStore`
      Parameters:
        `type` - the type of the resource
        `resourceServerId` - the resource server id
        `consumer` - the result consumer

    - #### findByType

          public void findByType(String type,
                                 String owner,
                                 String resourceServerId,
                                 Consumer<Resource> consumer)

      Description copied from interface: `ResourceStore`
      Finds all `Resource` with the given type.
      Specified by:
        `findByType` in interface `ResourceStore`
      Parameters:
        `type` - the type of the resource
        `owner` - the resource owner or null for any resource with a given type
        `resourceServerId` - the resource server id
        `consumer` - the result consumer

    - #### findByTypeInstance

          public void findByTypeInstance(String type,
                                         String resourceServerId,
                                         Consumer<Resource> consumer)

      Specified by:
        `findByTypeInstance` in interface `ResourceStore`

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