org.keycloak.authorization.jpa.store

## Class JPAPermissionTicketStore

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

- All Implemented Interfaces:
    PermissionTicketStore

      public class JPAPermissionTicketStore
      extends Object
      implements PermissionTicketStore

  Author:
    Pedro Igor

- - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `count(Map<PermissionTicket.FilterOption,String> attributes, String resourceServerId)` Returns count of `PermissionTicket`, filtered by the given attributes.
    `PermissionTicket` | `create(String resourceId, String scopeId, String requester, ResourceServer resourceServer)` Creates a new `PermissionTicket` instance.
    `void` | `delete(String id)` Deletes a permission from the underlying persistence mechanism.
    `List<PermissionTicket>` | `find(Map<PermissionTicket.FilterOption,String> attributes, String resourceServerId, int firstResult, int maxResult)` Returns a list of `PermissionTicket`, filtered by the given attributes.
    `PermissionTicket` | `findById(String id, String resourceServerId)` Returns a `PermissionTicket` with the given `id`
    `List<PermissionTicket>` | `findByOwner(String owner, String resourceServerId)` Returns a list of `PermissionTicket` associated with the given `owner`.
    `List<PermissionTicket>` | `findByResource(String resourceId, String resourceServerId)` Returns a list of `PermissionTicket` associated with a `org.keycloak.authorization.core.model.Resource` with the given `resourceId`.
    `List<PermissionTicket>` | `findByResourceServer(String resourceServerId)` Returns a list of `PermissionTicket` associated with a `ResourceServer` with the given `resourceServerId`.
    `List<PermissionTicket>` | `findByScope(String scopeId, String resourceServerId)` Returns a list of `PermissionTicket` associated with a `org.keycloak.authorization.core.model.Scope` with the given `scopeId`.
    `List<PermissionTicket>` | `findGranted(String userId, String resourceServerId)` Returns a list of `PermissionTicket` granted to the given `userId`.
    `List<PermissionTicket>` | `findGranted(String resourceName, String userId, String resourceServerId)` Returns a list of `PermissionTicket` with name equal to `resourceName` granted to the given `userId`.
    `List<Resource>` | `findGrantedOwnerResources(String owner, int first, int max)` Returns a list of `Resource` granted by the owner to other users
    `List<Resource>` | `findGrantedResources(String requester, String name, int first, int max)` Returns a list of `Resource` granted to the given `requester`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JPAPermissionTicketStore

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

  - ### Method Detail

    - #### count

          public long count(Map<PermissionTicket.FilterOption,String> attributes,
                            String resourceServerId)

      Description copied from interface: `PermissionTicketStore`
      Returns count of `PermissionTicket`, filtered by the given attributes.
      Specified by:
        `count` in interface `PermissionTicketStore`
      Parameters:
        `attributes` - permission tickets that do not match the attributes are not included with the count; possible filter options are given by `PermissionTicket.FilterOption`
        `resourceServerId` - the resource server id
      Returns:
        an integer indicating the amount of permission tickets

    - #### create

          public PermissionTicket create(String resourceId,
                                         String scopeId,
                                         String requester,
                                         ResourceServer resourceServer)

      Description copied from interface: `PermissionTicketStore`
      Creates a new `PermissionTicket` instance.
      Specified by:
        `create` in interface `PermissionTicketStore`
        `resourceServer` - the resource server to which this policy belongs
      Returns:
        a new instance of `PermissionTicket`

    - #### delete

          public void delete(String id)

      Description copied from interface: `PermissionTicketStore`
      Deletes a permission from the underlying persistence mechanism.
      Specified by:
        `delete` in interface `PermissionTicketStore`
      Parameters:
        `id` - the id of the policy to delete

    - #### findById

          public PermissionTicket findById(String id,
                                           String resourceServerId)

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

    - #### findByResourceServer

          public List<PermissionTicket> findByResourceServer(String resourceServerId)

      Description copied from interface: `PermissionTicketStore`
      Returns a list of `PermissionTicket` associated with a `ResourceServer` with the given `resourceServerId`.
      Specified by:
        `findByResourceServer` in interface `PermissionTicketStore`
      Parameters:
        `resourceServerId` - the identifier of a resource server
      Returns:
        a list of permissions belonging to the given resource server

    - #### findByResource

          public List<PermissionTicket> findByResource(String resourceId,
                                                       String resourceServerId)

      Description copied from interface: `PermissionTicketStore`
      Returns a list of `PermissionTicket` associated with a `org.keycloak.authorization.core.model.Resource` with the given `resourceId`.
      Specified by:
        `findByResource` in interface `PermissionTicketStore`
      Parameters:
        `resourceId` - the identifier of a resource
        `resourceServerId` - the resource server id
      Returns:
        a list of permissions associated with the given resource

    - #### findByScope

          public List<PermissionTicket> findByScope(String scopeId,
                                                    String resourceServerId)

      Description copied from interface: `PermissionTicketStore`
      Returns a list of `PermissionTicket` associated with a `org.keycloak.authorization.core.model.Scope` with the given `scopeId`.
      Specified by:
        `findByScope` in interface `PermissionTicketStore`
      Parameters:
        `scopeId` - the id of the scopes
        `resourceServerId` - the resource server id
      Returns:
        a list of permissions associated with the given scopes

    - #### find

          public List<PermissionTicket> find(Map<PermissionTicket.FilterOption,String> attributes,
                                             String resourceServerId,
                                             int firstResult,
                                             int maxResult)

      Description copied from interface: `PermissionTicketStore`
      Returns a list of `PermissionTicket`, filtered by the given attributes.
      Specified by:
        `find` in interface `PermissionTicketStore`
      Parameters:
        `attributes` - a map of keys and values to filter on; possible filter options are given by `PermissionTicket.FilterOption`
        `resourceServerId` - an id of resource server that resulting tickets should belong to. Ignored if `null`
        `firstResult` - first result to return; Ignored if negative or zero
        `maxResult` - maximum number of results to return; Ignored if negative
      Returns:
        a list of filtered and paginated permissions

    - #### findGranted

          public List<PermissionTicket> findGranted(String userId,
                                                    String resourceServerId)

      Description copied from interface: `PermissionTicketStore`
      Returns a list of `PermissionTicket` granted to the given `userId`.
      Specified by:
        `findGranted` in interface `PermissionTicketStore`
      Parameters:
        `userId` - the user id
        `resourceServerId` - the resource server id
      Returns:
        a list of permissions granted for a particular user

    - #### findGranted

          public List<PermissionTicket> findGranted(String resourceName,
                                                    String userId,
                                                    String resourceServerId)

      Description copied from interface: `PermissionTicketStore`
      Returns a list of `PermissionTicket` with name equal to `resourceName` granted to the given `userId`.
      Specified by:
        `findGranted` in interface `PermissionTicketStore`
      Parameters:
        `resourceName` - the name of a resource
        `userId` - the user id
        `resourceServerId` - the resource server id
      Returns:
        a list of permissions granted for a particular user

    - #### findGrantedResources

          public List<Resource> findGrantedResources(String requester,
                                                     String name,
                                                     int first,
                                                     int max)

      Description copied from interface: `PermissionTicketStore`
      Returns a list of `Resource` granted to the given `requester`
      Specified by:
        `findGrantedResources` in interface `PermissionTicketStore`
      Parameters:
        `requester` - the requester
        `name` - the keyword to query resources by name or null if any resource
        `first` - first result
        `max` - max result
      Returns:
        a list of `Resource` granted to the given `requester`

    - #### findGrantedOwnerResources

          public List<Resource> findGrantedOwnerResources(String owner,
                                                          int first,
                                                          int max)

      Description copied from interface: `PermissionTicketStore`
      Returns a list of `Resource` granted by the owner to other users
      Specified by:
        `findGrantedOwnerResources` in interface `PermissionTicketStore`
      Parameters:
        `owner` - the owner
        `first` - first result
        `max` - max result
      Returns:
        a list of `Resource` granted by the owner

    - #### findByOwner

          public List<PermissionTicket> findByOwner(String owner,
                                                    String resourceServerId)

      Description copied from interface: `PermissionTicketStore`
      Returns a list of `PermissionTicket` associated with the given `owner`.
      Specified by:
        `findByOwner` in interface `PermissionTicketStore`
      Parameters:
        `owner` - the identifier of a resource server
      Returns:
        a list of permissions belonging to the given owner

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