Class EvaluableCredentialCriteriaRegistry
- java.lang.Object
-
- org.opensaml.security.credential.criteria.impl.EvaluableCredentialCriteriaRegistry
-
public final class EvaluableCredentialCriteriaRegistry extends Object
A registry which manages mappings from types ofCriterionto the class type which can evaluate that criteria's data against a Credential target. That latter class will be a subtype ofEvaluableCredentialCriterion. Each EvaluableCredentialCriterion implementation that is registered MUST implement a single-arg constructor which takes an instance of the Criterion to be evaluated. The evaluable instance is instantiated reflectively based on this requirement.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_MAPPINGS_FILEProperties file storing default mappings from criteria to evaluable credential criteria.private static booleaninitializedFlag to track whether registry is initialized.private static org.slf4j.LoggerLOGLogger.private static Map<Class<? extends Criterion>,Class<? extends EvaluableCredentialCriterion>>registryStorage for the registry mappings.
-
Constructor Summary
Constructors Modifier Constructor Description privateEvaluableCredentialCriteriaRegistry()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclearRegistry()Clear all mappings from the registry.static voidderegister(Class<? extends Criterion> criteriaClass)Deregister a criteria-evaluator mapping.static EvaluableCredentialCriteriongetEvaluator(Criterion criteria)Get an instance ofEvaluableCredentialCriterionwhich can evaluate the supplied criteria's requirements against a Credential target.static voidinit()Initialize the registry.static booleanisInitialized()Check whether the registry has been initialized.static voidloadDefaultMappings()Load the default set of criteria-evaluator mappings from the default mappings properties file.static voidloadMappings(Properties mappings)Load a set of criteria-evaluator mappings from the supplied properties set.static Class<? extends EvaluableCredentialCriterion>lookup(Class<? extends Criterion> clazz)Lookup the class subtype of EvaluableCredentialCriterion which is registered for the specified Criterion class.static voidregister(Class<? extends Criterion> criteriaClass, Class<? extends EvaluableCredentialCriterion> evaluableClass)Register a credential evaluator class for a criteria class.
-
-
-
Field Detail
-
DEFAULT_MAPPINGS_FILE
public static final String DEFAULT_MAPPINGS_FILE
Properties file storing default mappings from criteria to evaluable credential criteria. Will be loaded as a resource stream relative to this class.- See Also:
- Constant Field Values
-
registry
private static Map<Class<? extends Criterion>,Class<? extends EvaluableCredentialCriterion>> registry
Storage for the registry mappings.
-
initialized
private static boolean initialized
Flag to track whether registry is initialized.
-
LOG
@Nonnull private static final org.slf4j.Logger LOG
Logger.
-
-
Method Detail
-
getEvaluator
@Nullable public static EvaluableCredentialCriterion getEvaluator(@Nonnull Criterion criteria) throws SecurityException
Get an instance ofEvaluableCredentialCriterionwhich can evaluate the supplied criteria's requirements against a Credential target.- Parameters:
criteria- the criteria to be evaluated against a credential- Returns:
- an instance of of EvaluableCredentialCriterion representing the specified criteria's requirements
- Throws:
SecurityException- thrown if there is an error reflectively instantiating a new instance of EvaluableCredentialCriterion based on class information stored in the registry
-
lookup
@Nullable public static Class<? extends EvaluableCredentialCriterion> lookup(@Nonnull Class<? extends Criterion> clazz)
Lookup the class subtype of EvaluableCredentialCriterion which is registered for the specified Criterion class.- Parameters:
clazz- the Criterion class subtype to lookup- Returns:
- the registered EvaluableCredentialCriterion class subtype
-
register
public static void register(@Nonnull Class<? extends Criterion> criteriaClass, @Nonnull Class<? extends EvaluableCredentialCriterion> evaluableClass)Register a credential evaluator class for a criteria class.- Parameters:
criteriaClass- class subtype ofCriterionevaluableClass- class subtype ofEvaluableCredentialCriterion
-
deregister
public static void deregister(@Nonnull Class<? extends Criterion> criteriaClass)Deregister a criteria-evaluator mapping.- Parameters:
criteriaClass- class subtype ofCriterion
-
clearRegistry
public static void clearRegistry()
Clear all mappings from the registry.
-
isInitialized
public static boolean isInitialized()
Check whether the registry has been initialized.- Returns:
- true if registry is already initialized, false otherwise
-
init
public static void init()
Initialize the registry.
-
loadDefaultMappings
public static void loadDefaultMappings()
Load the default set of criteria-evaluator mappings from the default mappings properties file.
-
loadMappings
public static void loadMappings(@Nonnull Properties mappings)Load a set of criteria-evaluator mappings from the supplied properties set.- Parameters:
mappings- properties set where the key is the criteria class name, the value is the evaluator class name
-
-