Package org.forgerock.openam.entitlement
Class EntitlementRegistry
- java.lang.Object
-
- org.forgerock.openam.entitlement.EntitlementRegistry
-
@SupportedAll public final class EntitlementRegistry extends Object
Provides methods for discovering and loading entitlements conditions and subject implementations. Builds upon the standard JavaServiceLoader
mechanism to allow additional entitlement condition and subject implementations to be registered by client extensions (seeEntitlementModule
).- Since:
- 12.0.0
-
-
Constructor Summary
Constructors Constructor Description EntitlementRegistry()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAttributeName(ResourceAttribute attribute)
Returns the short name that the given attribute is registered under.Set<String>
getAttributesShortNames()
Returns all the short names ofResourceAttribute
s currently registered in thisEntitlementRegistry
.Class<? extends ResourceAttribute>
getAttributeType(String name)
Returns the attribute type associated with the given short name, or null if no such attribute is registered.Class<? extends com.sun.identity.entitlement.EntitlementCombiner>
getCombiner(String name)
Returns the entitlement combiner if it is available in the registry.Set<String>
getCombinersShortNames()
Returns all the short names ofEntitlementCombiner
s currently registered in thisEntitlementRegistry
.Class<? extends com.sun.identity.entitlement.EntitlementCombiner>
getCombinerType(String name)
Returns the combiner associated with the given short name.String
getConditionName(EntitlementCondition condition)
Returns the short name that the given condition is registered under.Set<String>
getConditionsShortNames()
Returns all the short names ofEntitlementCondition
s currently registered in thisEntitlementRegistry
.Class<? extends EntitlementCondition>
getConditionType(String name)
Returns the condition type associated with the given short name, or null if no such condition is registered.static String
getConditionTypeName(Class<? extends EntitlementCondition> type)
Gets the name of the condition type.String
getSubjectName(EntitlementSubject subject)
Returns the short name that the given subject is registered under.Set<String>
getSubjectsShortNames()
Returns all the short names ofEntitlementSubject
s currently registered in thisEntitlementRegistry
.Class<? extends EntitlementSubject>
getSubjectType(String name)
Returns the subject type associated with the given short name, or null if no such subject is registered.static String
getSubjectTypeName(Class<? extends EntitlementSubject> type)
Gets the name of the subject type.static EntitlementRegistry
load()
Loads all availableEntitlementModule
instances and registers them with a new entitlement registry.void
registerAttributeType(Class<? extends ResourceAttribute> type)
Registers a resource attribute type using a short name generated from the type name.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).void
registerConditionType(Class<? extends EntitlementCondition> type)
Registers an entitlement condition type using a short name generated from the type name.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).void
registerDecisionCombiner(Class<? extends com.sun.identity.entitlement.EntitlementCombiner> type)
Registers an entitlement combiner.void
registerDecisionCombiner(String name, Class<? extends com.sun.identity.entitlement.EntitlementCombiner> type)
Registers an entitlement combiner with a given name.void
registerSubjectType(Class<? extends EntitlementSubject> type)
Registers an entitlement subject type using a short name generated from the type name.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).
-
-
-
Method Detail
-
load
public static EntitlementRegistry load()
Loads all availableEntitlementModule
instances and registers them with a new entitlement registry. Each invocation of this method will attempt to load any known entitlement modules as perServiceLoader.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 anyCondition
suffix. For example, a condition typeorg.forgerock.openam.entitlement.TestCondition
would be registered with the short nameTest
.- 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 anySubject
suffix. For example, a subject typeorg.forgerock.openam.entitlement.TestSubject
would be registered with the short nameTest
.- 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 anyAttribute
suffix. For example, an attribute typeorg.forgerock.openam.entitlement.TestAttribute
would be registered with the short nameTest
.- 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 ofEntitlementCondition
s currently registered in thisEntitlementRegistry
.- 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 ofEntitlementSubject
s currently registered in thisEntitlementRegistry
.- 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 ofResourceAttribute
s currently registered in thisEntitlementRegistry
.- 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 ofEntitlementCombiner
s currently registered in thisEntitlementRegistry
.- Returns:
- A set of strings containing all the unique EntitlementCombiners registered at point of query.
-
-