Class EntitlementRegistry


  • @SupportedAll
    public final class EntitlementRegistry
    extends Object
    Provides methods for discovering and loading entitlements conditions and subject implementations. Builds upon the standard Java ServiceLoader mechanism to allow additional entitlement condition and subject implementations to be registered by client extensions (see EntitlementModule).
    Since:
    12.0.0
    • Constructor Detail

      • EntitlementRegistry

        public EntitlementRegistry()
    • Method Detail

      • load

        public static EntitlementRegistry load()
        Loads all available EntitlementModule instances and registers them with a new entitlement registry. Each invocation of this method will attempt to load any known entitlement modules as per ServiceLoader.load(Class). Previously loaded modules will be cached but any newly available modules will be loaded.
        Returns:
        an entitlement registry populated with all known entitlement modules.
      • registerConditionType

        public void registerConditionType​(String name,
                                          Class<? extends EntitlementCondition> type)
        Registers an entitlement condition type with the given short name (used in RESTful API calls and in the UI). Note: short names must be unique across all condition types.
        Parameters:
        name - the short name of the condition type.
        type - the condition type to register.
        Throws:
        org.forgerock.openam.entitlement.NameAlreadyRegisteredException - if the short name is already registered.
      • registerConditionType

        public void registerConditionType​(Class<? extends EntitlementCondition> type)
        Registers an entitlement condition type using a short name generated from the type name. The short name is generated as the simple name of the class minus any Condition suffix. For example, a condition type org.forgerock.openam.entitlement.TestCondition would be registered with the short name Test.
        Parameters:
        type - the condition type to register.
        Throws:
        org.forgerock.openam.entitlement.NameAlreadyRegisteredException - if the short name is already registered.
      • getConditionType

        public Class<? extends EntitlementCondition> getConditionType​(String name)
        Returns the condition type associated with the given short name, or null if no such condition is registered.
        Parameters:
        name - the short name of the condition type to get.
        Returns:
        the associated condition type or null if no matching condition type is registered.
      • getConditionTypeName

        public static String getConditionTypeName​(Class<? extends EntitlementCondition> type)
        Gets the name of the condition type.
        Parameters:
        type - The type.
        Returns:
        The name.
      • registerDecisionCombiner

        public void registerDecisionCombiner​(Class<? extends com.sun.identity.entitlement.EntitlementCombiner> type)
        Registers an entitlement combiner.
        Parameters:
        type - the condition type to register.
        Throws:
        org.forgerock.openam.entitlement.NameAlreadyRegisteredException - if the short name is already registered.
      • registerDecisionCombiner

        public void registerDecisionCombiner​(String name,
                                             Class<? extends com.sun.identity.entitlement.EntitlementCombiner> type)
        Registers an entitlement combiner with a given name.
        Parameters:
        type - the combiner type to register.
        Throws:
        org.forgerock.openam.entitlement.NameAlreadyRegisteredException - if the short name is already registered.
      • getCombinerType

        public Class<? extends com.sun.identity.entitlement.EntitlementCombiner> getCombinerType​(String name)
        Returns the combiner associated with the given short name.
        Parameters:
        name - the short name of the combiner type to get.
        Returns:
        the associated combiner type or null if no matching combiner type is registered.
      • registerSubjectType

        public void registerSubjectType​(String name,
                                        Class<? extends EntitlementSubject> type)
        Registers an entitlement subject type with the given short name (used in RESTful API calls and in the UI). Note: short names must be unique across all subject types.
        Parameters:
        name - the short name of the subject type.
        type - the subject type to register.
        Throws:
        org.forgerock.openam.entitlement.NameAlreadyRegisteredException - if the short name is already registered.
      • registerSubjectType

        public void registerSubjectType​(Class<? extends EntitlementSubject> type)
        Registers an entitlement subject type using a short name generated from the type name. The short name is generated as the simple name of the class minus any Subject suffix. For example, a subject type org.forgerock.openam.entitlement.TestSubject would be registered with the short name Test.
        Parameters:
        type - the subject type to register.
        Throws:
        org.forgerock.openam.entitlement.NameAlreadyRegisteredException - if the short name is already registered.
      • getSubjectTypeName

        public static String getSubjectTypeName​(Class<? extends EntitlementSubject> type)
        Gets the name of the subject type.
        Parameters:
        type - The type.
        Returns:
        The name.
      • getSubjectType

        public Class<? extends EntitlementSubject> getSubjectType​(String name)
        Returns the subject type associated with the given short name, or null if no such subject is registered.
        Parameters:
        name - the short name of the subject type to get.
        Returns:
        the associated subject type or null if no matching subject type is registered.
      • registerAttributeType

        public void registerAttributeType​(String name,
                                          Class<? extends ResourceAttribute> type)
        Registers a resource attribute type with the given short name (used in RESTful API calls and in the UI). Note: short names must be unique across all resource attribute types.
        Parameters:
        name - the short name of the attribute type.
        type - the attribute type to register.
        Throws:
        org.forgerock.openam.entitlement.NameAlreadyRegisteredException - if the short name is already registered.
      • registerAttributeType

        public void registerAttributeType​(Class<? extends ResourceAttribute> type)
        Registers a resource attribute type using a short name generated from the type name. The short name is generated as the simple name of the class minus any Attribute suffix. For example, an attribute type org.forgerock.openam.entitlement.TestAttribute would be registered with the short name Test.
        Parameters:
        type - the attribute type to register.
        Throws:
        org.forgerock.openam.entitlement.NameAlreadyRegisteredException - if the short name is already registered.
      • getAttributeType

        public Class<? extends ResourceAttribute> getAttributeType​(String name)
        Returns the attribute type associated with the given short name, or null if no such attribute is registered.
        Parameters:
        name - the short name of the attribute type to get.
        Returns:
        the associated attribute type or null if no matching attribute type is registered.
      • getConditionName

        public String getConditionName​(EntitlementCondition condition)
        Returns the short name that the given condition is registered under. If the condition is registered under multiple names then an arbitrary name is returned. If the condition type is not registered then null is returned.
        Parameters:
        condition - the condition to get a short name for.
        Returns:
        the short type name of the given condition or null if not registered.
      • getSubjectName

        public String getSubjectName​(EntitlementSubject subject)
        Returns the short name that the given subject is registered under. If the subject is registered under multiple names then an arbitrary name is returned. If the subject type is not registered then null is returned.
        Parameters:
        subject - the subject to get a short name for.
        Returns:
        the short type name of the given subject or null if not registered.
      • getAttributeName

        public String getAttributeName​(ResourceAttribute attribute)
        Returns the short name that the given attribute is registered under. If the attribute is registered under multiple names then an arbitrary name is returned. If the attribute type is not registered then null is returned.
        Parameters:
        attribute - the attribute to get a short name for.
        Returns:
        the short type name of the given attribute or null if not registered.
      • getConditionsShortNames

        public Set<String> getConditionsShortNames()
        Returns all the short names of EntitlementConditions currently registered in this EntitlementRegistry.
        Returns:
        A set of strings containing all the unique EntitlementConditions registered at point of query.
      • getSubjectsShortNames

        public Set<String> getSubjectsShortNames()
        Returns all the short names of EntitlementSubjects currently registered in this EntitlementRegistry.
        Returns:
        A set of strings containing all the unique EntitlementSubject registered at point of query.
      • getAttributesShortNames

        public Set<String> getAttributesShortNames()
        Returns all the short names of ResourceAttributes currently registered in this EntitlementRegistry.
        Returns:
        A set of strings containing all the unique ResourceAttribute registered at point of query.
      • getCombinersShortNames

        public Set<String> getCombinersShortNames()
        Returns all the short names of EntitlementCombiners currently registered in this EntitlementRegistry.
        Returns:
        A set of strings containing all the unique EntitlementCombiners registered at point of query.
      • getCombiner

        public Class<? extends com.sun.identity.entitlement.EntitlementCombiner> getCombiner​(String name)
        Returns the entitlement combiner if it is available in the registry.
        Parameters:
        name - the fully qualified class name of the entitlement combiner
        Returns:
        The entitlement combiner.