public class AlgorithmRegistry extends Object
AlgorithmDescriptor
instances, to support various use cases for working with algorithm URIs.Modifier and Type | Class and Description |
---|---|
protected class |
AlgorithmRegistry.SignatureAlgorithmIndex
Class used as index key for signature algorithm lookup.
|
Modifier and Type | Field and Description |
---|---|
private Map<String,AlgorithmDescriptor> |
descriptors
Map of registered algorithm descriptors.
|
private Map<String,DigestAlgorithm> |
digestAlgorithms
Index of digest type to AlgorithmDescriptor.
|
private org.slf4j.Logger |
log
Logger.
|
private Set<String> |
runtimeSupported
Set containing algorithms which are supported by the runtime environment.
|
private Map<AlgorithmRegistry.SignatureAlgorithmIndex,SignatureAlgorithm> |
signatureAlgorithms
Index of (KeyType,DigestType) to AlgorithmDescriptor.
|
Constructor and Description |
---|
AlgorithmRegistry()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
checkCipherSupportedKeyLength(AlgorithmDescriptor descriptor)
Check if the key length of the specified
Cipher -based algorithm, if known, is
supported by the current runtime. |
private boolean |
checkRuntimeSupports(AlgorithmDescriptor descriptor)
Evaluate whether the algorithm is supported by the current runtime environment.
|
private boolean |
checkSpecialCasesRuntimeSupport(AlgorithmDescriptor descriptor)
Check for special cases of runtime support which failed the initial simple service class load check.
|
void |
clear()
Clear all registered algorithms.
|
private void |
deindex(AlgorithmDescriptor descriptor)
Remove the algorithm descriptor from the indexes which support the various lookup methods
available via the registry's API.
|
void |
deregister(AlgorithmDescriptor descriptor)
Deregister an algorithm.
|
void |
deregister(String uri)
Deregister an algorithm.
|
AlgorithmDescriptor |
get(String algorithmURI)
Get the algorithm descriptor instance associated with the specified algorithm URI.
|
DigestAlgorithm |
getDigestAlgorithm(String digestMethod)
Lookup a digest method algorithm descriptor by the JCA digest method ID.
|
SignatureAlgorithm |
getSignatureAlgorithm(String keyType,
String digestMethod)
Lookup a signature algorithm descriptor by the JCA key algorithm and digest method IDs.
|
private void |
index(AlgorithmDescriptor descriptor)
Add the algorithm descriptor to the indexes which support the various lookup methods
available via the registry's API.
|
boolean |
isRuntimeSupported(String algorithmURI)
Retrieve indication of whether the runtime environment supports the algorithm.
|
void |
register(AlgorithmDescriptor descriptor)
Register an algorithm.
|
private org.slf4j.Logger log
private Map<String,AlgorithmDescriptor> descriptors
private Set<String> runtimeSupported
private Map<String,DigestAlgorithm> digestAlgorithms
private Map<AlgorithmRegistry.SignatureAlgorithmIndex,SignatureAlgorithm> signatureAlgorithms
@Nullable public AlgorithmDescriptor get(@Nullable String algorithmURI)
algorithmURI
- the algorithm URI to resolvepublic boolean isRuntimeSupported(@Nullable String algorithmURI)
This evaluation is performed dynamically when the algorithm is registered.
algorithmURI
- the algorithm URI to evaluatepublic void clear()
public void register(@Nonnull AlgorithmDescriptor descriptor)
descriptor
- the algorithmpublic void deregister(@Nonnull AlgorithmDescriptor descriptor)
descriptor
- the algorithmpublic void deregister(@Nonnull String uri)
uri
- the algorithm URI@Nullable public DigestAlgorithm getDigestAlgorithm(@Nonnull String digestMethod)
digestMethod
- the JCA digest method ID.@Nullable public SignatureAlgorithm getSignatureAlgorithm(@Nonnull String keyType, @Nonnull String digestMethod)
keyType
- the JCA key algorithm ID.digestMethod
- the JCA digest method ID.private void index(AlgorithmDescriptor descriptor)
descriptor
- the algorithmprivate void deindex(AlgorithmDescriptor descriptor)
descriptor
- the algorithmprivate boolean checkRuntimeSupports(AlgorithmDescriptor descriptor)
descriptor
- the algorithmprivate boolean checkCipherSupportedKeyLength(AlgorithmDescriptor descriptor) throws NoSuchAlgorithmException
Cipher
-based algorithm, if known, is
supported by the current runtime.descriptor
- the algorithmNoSuchAlgorithmException
- if the associated JCA algorithm is not supported by the runtimeprivate boolean checkSpecialCasesRuntimeSupport(AlgorithmDescriptor descriptor)
descriptor
- the algorithmCopyright © 1999–2020 Shibboleth Consortium. All rights reserved.