Interface PolicyStore

    • Method Detail

      • create

        Policy create​(ResourceServer resourceServer,
                      AbstractPolicyRepresentation representation)
        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:
        resourceServer - the resource server to which this policy belongs
        representation - the policy representation
        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​(ResourceServer resourceServer,
                        String id)
        Returns a Policy with the given id
        Parameters:
        resourceServer - the resource server
        id - the identifier of the policy
        Returns:
        a policy with the given identifier.
      • findByName

        Policy findByName​(ResourceServer resourceServer,
                          String name)
        Returns a Policy with the given name
        Parameters:
        resourceServer - the resource server
        name - the name of the policy
        Returns:
        a policy with the given name.
      • findByResourceServer

        List<Policy> findByResourceServer​(ResourceServer resourceServer)
        Returns a list of Policy associated with a ResourceServer with the given resourceServerId.
        Parameters:
        resourceServer - the identifier of a resource server
        Returns:
        a list of policies that belong to the given resource server
      • findByResourceServer

        List<Policy> findByResourceServer​(ResourceServer resourceServer,
                                          Map<Policy.FilterOption,​String[]> attributes,
                                          Integer firstResult,
                                          Integer maxResults)
        Returns a list of Policy associated with a ResourceServer with the given resourceServerId.
        Parameters:
        resourceServer - the identifier of a resource server
        attributes - a map holding the attributes that will be used as a filter; possible filter options are given by Policy.FilterOption
        firstResult - first result to return. Ignored if negative or null.
        maxResults - maximum number of results to return. Ignored if negative or null.
        Returns:
        a list of policies that belong to the given resource server
        Throws:
        IllegalArgumentException - when there is an unknown attribute in the attributes map
      • findByResource

        default List<Policy> findByResource​(ResourceServer resourceServer,
                                            Resource resource)
        Returns a list of Policy associated with a Resource with the given resourceId.
        Parameters:
        resourceServer - the resource server
        resource - the resource
        Returns:
        a list of policies associated with the given resource
      • findByResource

        void findByResource​(ResourceServer resourceServer,
                            Resource resource,
                            Consumer<Policy> consumer)
        Searches for all policies associated with the Resource and passes the result to the consumer
        Parameters:
        resourceServer - the resourceServer
        resource - the resource
        consumer - consumer of policies resulted from the search
      • findByResourceType

        default List<Policy> findByResourceType​(ResourceServer resourceServer,
                                                String resourceType)
        Returns a list of Policy associated with a ResourceServer with the given type.
        Parameters:
        resourceServer - the resource server id
        resourceType - the type of a resource
        Returns:
        a list of policies associated with the given resource type
      • findByResourceType

        void findByResourceType​(ResourceServer resourceServer,
                                String type,
                                Consumer<Policy> policyConsumer)
        Searches for policies associated with a ResourceServer and passes the result to the consumer
        Parameters:
        resourceServer - the resourceServer
        type - the type of a resource
        policyConsumer - consumer of policies resulted from the search
      • findByScopes

        List<Policy> findByScopes​(ResourceServer resourceServer,
                                  List<Scope> scopes)
        Returns a list of Policy associated with a Scope within the given scope.
        Parameters:
        resourceServer - the resource server
        scopes - the scopes
        Returns:
        a list of policies associated with the given scopes
      • findByScopes

        default List<Policy> findByScopes​(ResourceServer resourceServer,
                                          Resource resource,
                                          List<Scope> scopes)
        Returns a list of Policy associated with a Scope with the given resource and scopes.
        Parameters:
        resourceServer - the resource server
        resource - the resource. Ignored if null.
        scopes - the scopes
        Returns:
        a list of policies associated with the given scopes
      • findByType

        List<Policy> findByType​(ResourceServer resourceServer,
                                String type)
        Returns a list of Policy with the given type.
        Parameters:
        resourceServer - the resource server id
        type - the type of the policy
        Returns:
        a list of policies with the given type
      • findDependentPolicies

        List<Policy> findDependentPolicies​(ResourceServer resourceServer,
                                           String id)
        Returns a list of Policy that depends on another policy with the given id.
        Parameters:
        resourceServer - the resource server
        id - the id of the policy to query its dependents
        Returns:
        a list of policies that depends on the a policy with the given identifier