Package org.keycloak.authorization.store
Interface PermissionTicketStore
-
public interface PermissionTicketStoreAPermissionTicketStoreis responsible to manage the persistence ofPermissionTicketinstances.- Author:
- Pedro Igor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longcount(ResourceServer resourceServer, Map<PermissionTicket.FilterOption,String> attributes)Returns count ofPermissionTicket, filtered by the given attributes.PermissionTicketcreate(ResourceServer resourceServer, Resource resource, Scope scope, String requester)Creates a newPermissionTicketinstance.voiddelete(String id)Deletes a permission from the underlying persistence mechanism.List<PermissionTicket>find(ResourceServer resourceServer, Map<PermissionTicket.FilterOption,String> attributes, Integer firstResult, Integer maxResults)Returns a list ofPermissionTicket, filtered by the given attributes.PermissionTicketfindById(ResourceServer resourceServer, String id)Returns aPermissionTicketwith the givenidList<PermissionTicket>findByOwner(ResourceServer resourceServer, String owner)Returns a list ofPermissionTicketassociated with the givenowner.List<PermissionTicket>findByResource(ResourceServer resourceServer, Resource resource)Returns a list ofPermissionTicketassociated with theresource.List<PermissionTicket>findByResourceServer(ResourceServer resourceServer)Returns a list ofPermissionTicketassociated with aResourceServer.List<PermissionTicket>findByScope(ResourceServer resourceServer, Scope scope)Returns a list ofPermissionTicketassociated with thescope.List<PermissionTicket>findGranted(ResourceServer resourceServer, String userId)Returns a list ofPermissionTicketgranted to the givenuserId.List<PermissionTicket>findGranted(ResourceServer resourceServer, String resourceName, String userId)List<Resource>findGrantedOwnerResources(String owner, Integer firstResult, Integer maxResults)Returns a list ofResourcegranted by the owner to other usersList<Resource>findGrantedResources(String requester, String name, Integer firstResult, Integer maxResults)Returns a list ofResourcegranted to the givenrequester
-
-
-
Method Detail
-
count
long count(ResourceServer resourceServer, Map<PermissionTicket.FilterOption,String> attributes)
Returns count ofPermissionTicket, filtered by the given attributes.- Parameters:
resourceServer- the resource serverattributes- permission tickets that do not match the attributes are not included with the count; possible filter options are given byPermissionTicket.FilterOption- Returns:
- an integer indicating the amount of permission tickets
- Throws:
IllegalArgumentException- when there is an unknown attribute in theattributesmap
-
create
PermissionTicket create(ResourceServer resourceServer, Resource resource, Scope scope, String requester)
Creates a newPermissionTicketinstance.- Parameters:
resourceServer- the resource server to which this policy belongsresource- resource idscope- scope idrequester- the policy representation- Returns:
- a new instance of
PermissionTicket
-
delete
void delete(String id)
Deletes a permission from the underlying persistence mechanism.- Parameters:
id- the id of the policy to delete
-
findById
PermissionTicket findById(ResourceServer resourceServer, String id)
Returns aPermissionTicketwith the givenid- Parameters:
resourceServer- the resource serverid- the identifier of the permission- Returns:
- a permission with the given identifier.
-
findByResourceServer
List<PermissionTicket> findByResourceServer(ResourceServer resourceServer)
Returns a list ofPermissionTicketassociated with aResourceServer.- Parameters:
resourceServer- the resource server- Returns:
- a list of permissions belonging to the given resource server
-
findByOwner
List<PermissionTicket> findByOwner(ResourceServer resourceServer, String owner)
Returns a list ofPermissionTicketassociated with the givenowner.- Parameters:
resourceServer- the resource serverowner- the identifier of a resource server- Returns:
- a list of permissions belonging to the given owner
-
findByResource
List<PermissionTicket> findByResource(ResourceServer resourceServer, Resource resource)
Returns a list ofPermissionTicketassociated with theresource.- Parameters:
resourceServer- the resource serverresource- the resource- Returns:
- a list of permissions associated with the given resource TODO: maybe we can get rid of reosourceServer param here as resource has method getResourceServer()
-
findByScope
List<PermissionTicket> findByScope(ResourceServer resourceServer, Scope scope)
Returns a list ofPermissionTicketassociated with thescope.- Parameters:
resourceServer- the resource serverscope- the scope- Returns:
- a list of permissions associated with the given scopes TODO: maybe we can get rid of reosourceServer param here as resource has method getResourceServer()
-
find
List<PermissionTicket> find(ResourceServer resourceServer, Map<PermissionTicket.FilterOption,String> attributes, Integer firstResult, Integer maxResults)
Returns a list ofPermissionTicket, filtered by the given attributes.- Parameters:
resourceServer- a resource server that resulting tickets should belong to. Ignored ifnullattributes- a map of keys and values to filter on; possible filter options are given byPermissionTicket.FilterOptionfirstResult- first result to return. Ignored if negative ornull.maxResults- maximum number of results to return. Ignored if negative ornull.- Returns:
- a list of filtered and paginated permissions
- Throws:
IllegalArgumentException- when there is an unknown attribute in theattributesmap
-
findGranted
List<PermissionTicket> findGranted(ResourceServer resourceServer, String userId)
Returns a list ofPermissionTicketgranted to the givenuserId.- Parameters:
resourceServer- the resource serveruserId- the user id- Returns:
- a list of permissions granted for a particular user
-
findGranted
List<PermissionTicket> findGranted(ResourceServer resourceServer, String resourceName, String userId)
- Parameters:
resourceServer- the resource serverresourceName- the name of a resourceuserId- the user id- Returns:
- a list of permissions granted for a particular user TODO: investigate a way how to replace resourceName with Resource class
-
findGrantedResources
List<Resource> findGrantedResources(String requester, String name, Integer firstResult, Integer maxResults)
Returns a list ofResourcegranted to the givenrequester- Parameters:
requester- the requestername- the keyword to query resources by name or null if any resourcefirstResult- first result to return. Ignored if negative ornull.maxResults- maximum number of results to return. Ignored if negative ornull.- Returns:
- a list of
Resourcegranted to the givenrequester
-
findGrantedOwnerResources
List<Resource> findGrantedOwnerResources(String owner, Integer firstResult, Integer maxResults)
Returns a list ofResourcegranted by the owner to other users- Parameters:
owner- the ownerfirstResult- first result to return. Ignored if negative ornull.maxResults- maximum number of results to return. Ignored if negative ornull.- Returns:
- a list of
Resourcegranted by the owner
-
-