Package org.opensaml.xmlsec.algorithm
Class AlgorithmRegistry
java.lang.Object
org.opensaml.xmlsec.algorithm.AlgorithmRegistry
A registry of
AlgorithmDescriptor instances, to support various use cases for working with algorithm URIs.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classClass used as index key for signature algorithm lookup. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String,AlgorithmDescriptor> Map of registered algorithm descriptors.private Map<String,DigestAlgorithm> Index of digest type to AlgorithmDescriptor.private org.slf4j.LoggerLogger.Set containing algorithms which are supported by the runtime environment.Index of (KeyType,DigestType) to AlgorithmDescriptor.private Map<AlgorithmDescriptor.AlgorithmType,Set<String>> Index of registered AlgorithmType to algorithm URI. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancheckCipherSupportedKeyLength(AlgorithmDescriptor descriptor) Check if the key length of the specifiedCipher-based algorithm, if known, is supported by the current runtime.private booleancheckRuntimeSupports(AlgorithmDescriptor descriptor) Evaluate whether the algorithm is supported by the current runtime environment.private booleancheckSpecialCasesRuntimeSupport(AlgorithmDescriptor descriptor) Check for special cases of runtime support which failed the initial simple service class load check.voidclear()Clear all registered algorithms.private voiddeindex(AlgorithmDescriptor descriptor) Remove the algorithm descriptor from the indexes which support the various lookup methods available via the registry's API.voidderegister(String uri) Deregister an algorithm.voidderegister(AlgorithmDescriptor descriptor) Deregister an algorithm.Get the algorithm descriptor instance associated with the specified algorithm URI.getDigestAlgorithm(String digestMethod) Lookup a digest method algorithm descriptor by the JCA digest method ID.Get the set ofAlgorithmDescriptorregistered for the given type.Get the set of algorithm URIs registered for the given type.getSignatureAlgorithm(String keyType, String digestMethod) Deprecated.getSignatureAlgorithms(String keyType, String digestMethod) Lookup signature algorithm descriptors by the JCA key algorithm and digest method IDs.private voidindex(AlgorithmDescriptor descriptor) Add the algorithm descriptor to the indexes which support the various lookup methods available via the registry's API.booleanisRuntimeSupported(String algorithmURI) Retrieve indication of whether the runtime environment supports the algorithm.voidregister(AlgorithmDescriptor descriptor) Register an algorithm.
-
Field Details
-
log
@Nonnull private org.slf4j.Logger logLogger. -
descriptors
Map of registered algorithm descriptors. -
types
Index of registered AlgorithmType to algorithm URI. -
runtimeSupported
Set containing algorithms which are supported by the runtime environment. -
digestAlgorithms
Index of digest type to AlgorithmDescriptor. -
signatureAlgorithms
@Nonnull private Map<AlgorithmRegistry.SignatureAlgorithmIndex,SignatureAlgorithm> signatureAlgorithmsIndex of (KeyType,DigestType) to AlgorithmDescriptor.
-
-
Constructor Details
-
AlgorithmRegistry
public AlgorithmRegistry()Constructor.
-
-
Method Details
-
get
Get the algorithm descriptor instance associated with the specified algorithm URI.- Parameters:
algorithmURI- the algorithm URI to resolve- Returns:
- the resolved algorithm descriptor or null
-
isRuntimeSupported
Retrieve indication of whether the runtime environment supports the algorithm.This evaluation is performed dynamically when the algorithm is registered.
- Parameters:
algorithmURI- the algorithm URI to evaluate- Returns:
- true if the algorithm is supported by the current runtime environment, false otherwise
-
clear
public void clear()Clear all registered algorithms. -
register
Register an algorithm.- Parameters:
descriptor- the algorithm
-
deregister
Deregister an algorithm.- Parameters:
descriptor- the algorithm
-
deregister
Deregister an algorithm.- Parameters:
uri- the algorithm URI
-
getDigestAlgorithm
Lookup a digest method algorithm descriptor by the JCA digest method ID.- Parameters:
digestMethod- the JCA digest method ID.- Returns:
- the algorithm descriptor, or null
-
getSignatureAlgorithm
@Deprecated @Nullable public SignatureAlgorithm getSignatureAlgorithm(@Nonnull String keyType, @Nonnull String digestMethod) Deprecated.Use insteadgetSignatureAlgorithms(String, String)Lookup a signature algorithm descriptor by the JCA key algorithm and digest method IDs.- Parameters:
keyType- the JCA key algorithm ID.digestMethod- the JCA digest method ID.- Returns:
- the algorithm descriptor, or null
-
getSignatureAlgorithms
@Nonnull public Set<SignatureAlgorithm> getSignatureAlgorithms(@Nonnull String keyType, @Nonnull String digestMethod) Lookup signature algorithm descriptors by the JCA key algorithm and digest method IDs.- Parameters:
keyType- the JCA key algorithm ID.digestMethod- the JCA digest method ID.- Returns:
- the list of matching algorithm descriptors, possibly empty
-
getRegisteredURIsByType
@Nonnull @Unmodifiable @NotLive public Set<String> getRegisteredURIsByType(@Nonnull AlgorithmDescriptor.AlgorithmType type) Get the set of algorithm URIs registered for the given type.- Parameters:
type- the algorithm type- Returns:
- the set of URIs for the given type, may be empty
-
getRegisteredByType
@Nonnull @Unmodifiable @NotLive public Set<AlgorithmDescriptor> getRegisteredByType(@Nonnull AlgorithmDescriptor.AlgorithmType type) Get the set ofAlgorithmDescriptorregistered for the given type.- Parameters:
type- the algorithm type- Returns:
- the set of descriptors for the given type, may be empty
-
index
Add the algorithm descriptor to the indexes which support the various lookup methods available via the registry's API.- Parameters:
descriptor- the algorithm
-
deindex
Remove the algorithm descriptor from the indexes which support the various lookup methods available via the registry's API.- Parameters:
descriptor- the algorithm
-
checkRuntimeSupports
Evaluate whether the algorithm is supported by the current runtime environment.- Parameters:
descriptor- the algorithm- Returns:
- true if runtime supports the algorithm, false otherwise
-
checkCipherSupportedKeyLength
private boolean checkCipherSupportedKeyLength(@Nonnull AlgorithmDescriptor descriptor) throws NoSuchAlgorithmException Check if the key length of the specifiedCipher-based algorithm, if known, is supported by the current runtime.- Parameters:
descriptor- the algorithm- Returns:
- true if key length supported, false otherwise
- Throws:
NoSuchAlgorithmException- if the associated JCA algorithm is not supported by the runtime
-
checkSpecialCasesRuntimeSupport
Check for special cases of runtime support which failed the initial simple service class load check.- Parameters:
descriptor- the algorithm- Returns:
- true if algorithm is supported by the runtime environment, false otherwise
-
getSignatureAlgorithms(String, String)