Class JPAPolicyStore

    • Constructor Detail

      • JPAPolicyStore

        public JPAPolicyStore​(javax.persistence.EntityManager entityManager,
                              AuthorizationProvider provider)
    • Method Detail

      • create

        public Policy create​(ResourceServer resourceServer,
                             AbstractPolicyRepresentation representation)
        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:
        resourceServer - the resource server to which this policy belongs
        representation - the policy representation
        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​(ResourceServer resourceServer,
                               String id)
        Description copied from interface: PolicyStore
        Returns a Policy with the given id
        Specified by:
        findById in interface PolicyStore
        Parameters:
        resourceServer - the resource server
        id - the identifier of the policy
        Returns:
        a policy with the given identifier.
      • findByName

        public Policy findByName​(ResourceServer resourceServer,
                                 String name)
        Description copied from interface: PolicyStore
        Returns a Policy with the given name
        Specified by:
        findByName in interface PolicyStore
        Parameters:
        resourceServer - the resource server
        name - the name of the policy
        Returns:
        a policy with the given name.
      • findByResourceServer

        public List<Policy> findByResourceServer​(ResourceServer resourceServer)
        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:
        resourceServer - the identifier of a resource server
        Returns:
        a list of policies that belong to the given resource server
      • findByResourceServer

        public List<Policy> findByResourceServer​(ResourceServer resourceServer,
                                                 Map<Policy.FilterOption,​String[]> attributes,
                                                 Integer firstResult,
                                                 Integer maxResults)
        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:
        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
      • findByResource

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

        public void findByResourceType​(ResourceServer resourceServer,
                                       String resourceType,
                                       Consumer<Policy> consumer)
        Description copied from interface: PolicyStore
        Searches for policies associated with a ResourceServer and passes the result to the consumer
        Specified by:
        findByResourceType in interface PolicyStore
        Parameters:
        resourceServer - the resourceServer
        resourceType - the type of a resource
        consumer - consumer of policies resulted from the search
      • findByScopes

        public List<Policy> findByScopes​(ResourceServer resourceServer,
                                         List<Scope> scopes)
        Description copied from interface: PolicyStore
        Returns a list of Policy associated with a Scope within the given scope.
        Specified by:
        findByScopes in interface PolicyStore
        Parameters:
        resourceServer - the resource server
        scopes - the scopes
        Returns:
        a list of policies associated with the given scopes
      • findByType

        public List<Policy> findByType​(ResourceServer resourceServer,
                                       String type)
        Description copied from interface: PolicyStore
        Returns a list of Policy with the given type.
        Specified by:
        findByType in interface PolicyStore
        Parameters:
        resourceServer - the resource server id
        type - the type of the policy
        Returns:
        a list of policies with the given type
      • findDependentPolicies

        public List<Policy> findDependentPolicies​(ResourceServer resourceServer,
                                                  String policyId)
        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:
        resourceServer - the resource server
        policyId - the id of the policy to query its dependents
        Returns:
        a list of policies that depends on the a policy with the given identifier