Class AlgorithmRegistryImpl
- java.lang.Object
-
- se.swedenconnect.security.algorithms.impl.AlgorithmRegistryImpl
-
- All Implemented Interfaces:
AlgorithmRegistry
- Direct Known Subclasses:
StaticAlgorithmRegistry
public class AlgorithmRegistryImpl extends Object implements AlgorithmRegistry
Default implementation of theAlgorithmRegistryinterface.- Author:
- Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
-
-
Constructor Summary
Constructors Constructor Description AlgorithmRegistryImpl()Default constructor.AlgorithmRegistryImpl(List<Algorithm> registry)Constructor setting up the registry according to the supplied list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AlgorithmgetAlgorithm(String algorithmUri)Gets the algorithm based on its URI.<T extends Algorithm>
TgetAlgorithm(String algorithmUri, Class<T> clazz)Gets an algorithm based on its URI and type.AlgorithmgetAlgorithm(Predicate<Algorithm> predicate)Gets the first algorithm that matches the supplied predicate.<T extends Algorithm>
TgetAlgorithm(Predicate<Algorithm> predicate, Class<T> clazz)Gets the first algorithm that matches the given type and supplied predicate.List<Algorithm>getAlgorithms(Predicate<Algorithm> predicate)Gets all algorithms that matches the supplied predicate.<T extends Algorithm>
List<T>getAlgorithms(Predicate<Algorithm> predicate, Class<T> clazz)Gets all algorithms that matches the given type and the supplied predicate.voidregister(Algorithm algorithm)Registers the given algorithm in the registry.voidunregister(String algorithmUri)Removes the given algorithm from the registry.
-
-
-
Method Detail
-
register
public void register(Algorithm algorithm)
Registers the given algorithm in the registry.- Parameters:
algorithm- the algorithm to register
-
unregister
public void unregister(String algorithmUri)
Removes the given algorithm from the registry.- Parameters:
algorithmUri- the algorithm URI
-
getAlgorithm
public Algorithm getAlgorithm(String algorithmUri)
Gets the algorithm based on its URI.- Specified by:
getAlgorithmin interfaceAlgorithmRegistry- Parameters:
algorithmUri- the algorithm URI- Returns:
- the algorithm, or null if none is found
-
getAlgorithm
public <T extends Algorithm> T getAlgorithm(String algorithmUri, Class<T> clazz)
Gets an algorithm based on its URI and type.- Specified by:
getAlgorithmin interfaceAlgorithmRegistry- Type Parameters:
T- the algorithm type- Parameters:
algorithmUri- the algorithm URIclazz- the type representing the algorithm- Returns:
- the algorithm, or null if none is found
-
getAlgorithm
public <T extends Algorithm> T getAlgorithm(Predicate<Algorithm> predicate, Class<T> clazz)
Gets the first algorithm that matches the given type and supplied predicate.If more than one algorithm matches the supplied predicate, the one with the lowest order is returned.
- Specified by:
getAlgorithmin interfaceAlgorithmRegistry- Parameters:
predicate- the predicate to applyclazz- the type representing the algorithm- Returns:
- an Algorithm or null if no algorithms in the registry matches
- See Also:
AlgorithmPredicates
-
getAlgorithm
public Algorithm getAlgorithm(Predicate<Algorithm> predicate)
Gets the first algorithm that matches the supplied predicate.If more than one algorithm matches the supplied predicate, the one with the lowest order is returned.
- Specified by:
getAlgorithmin interfaceAlgorithmRegistry- Parameters:
predicate- the predicate to apply- Returns:
- an Algorithm or null if no algorithms in the registry matches
- See Also:
AlgorithmPredicates
-
getAlgorithms
public List<Algorithm> getAlgorithms(Predicate<Algorithm> predicate)
Gets all algorithms that matches the supplied predicate.The list is sorted with the lowest algorithms with the lowest order index first.
- Specified by:
getAlgorithmsin interfaceAlgorithmRegistry- Parameters:
predicate- the predicate to apply- Returns:
- a (possibly empty) list of Algorithm objects
-
getAlgorithms
public <T extends Algorithm> List<T> getAlgorithms(Predicate<Algorithm> predicate, Class<T> clazz)
Gets all algorithms that matches the given type and the supplied predicate.The list is sorted with the lowest algorithms with the lowest order index first.
- Specified by:
getAlgorithmsin interfaceAlgorithmRegistry- Parameters:
predicate- the predicate to applyclazz- the type representing the algorithm- Returns:
- a (possibly empty) list of Algorithm objects
-
-