Class CryptoCatalog
CryptoAlgorithm implementations,
with utilities to validate and serialize the catalog.
CryptoCatalog is a lightweight registry built at a point in time via
load(). It consumes the authoritative provider registry owned by
CryptoAlgorithms and exposes:
validate()— sanity checks that each algorithm publishes at least one capability or key builder,toJson()— a compact JSON description of algorithms, capabilities, and registered key builders, andtoXml()— an XML rendition of the same data.
Identity and uniqueness
Algorithm ids are treated as canonical keys. Duplicate provider identifiers are rejected when the authoritative registry is initialized.Immutability & thread-safety
After construction, the internal map is unmodifiable and safe to share across threads. This class performs no lazy discovery or on-demand mutation.Serialization formats
- JSON: produced by
toJson()as a single object with analgorithmsarray; trivial string escaping is applied. - XML: produced by
toXml()with a<cryptoCatalog>root;&<>escaping is applied to element text and attributes.
Note: Default spec / key-spec values shown in outputs are stable metadata values resolved when providers are initialized; their intent is documentation, not round-tripping.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic CryptoCatalogload()Returns a catalog view of the authoritative registry initialized byCryptoAlgorithms.toJson()Serializes the catalog to a compact JSON document.toXml()Serializes the catalog to an XML document.voidvalidate()Verifies that each algorithm in this catalog exposes at least one capability or key builder.
-
Method Details
-
load
Returns a catalog view of the authoritative registry initialized byCryptoAlgorithms.Provider discovery, deterministic ordering, and duplicate checking occur once in
CryptoAlgorithms. This method neither scans providers nor copies their collection.- Returns:
- an immutable
CryptoCatalogwith all discovered algorithms - Throws:
ExceptionInInitializerError- if authoritative provider initialization fails
-
validate
public void validate()Verifies that each algorithm in this catalog exposes at least one capability or key builder.This is a sanity check for provider completeness. If an algorithm publishes neither
capabilitiesnor asymmetric/symmetric key builders, the validation fails.- Throws:
IllegalStateException- if any algorithm has no capabilities and no key builders
-
toJson
Serializes the catalog to a compact JSON document.The schema is:
{ "algorithms": [ { "id": "AES/GCM", "displayName": "AES-GCM", "capabilities": [ { "family": "SYMMETRIC", "role": "ENCRYPT", "contextType": "AeadEncryptContext", "keyType": "SecretKey", "specType": "AeadSpec", "defaultSpec": "Random nonce, 128-bit tag" } ], "asymmetricKeyBuilders": [ { "specType": "Ed25519Spec", "defaultKeySpec": "Ed25519 default" } ], "symmetricKeyBuilders": [ { "specType": "AesKeySpec", "defaultKeySpec": "AES-256" } ] } ] }String values are escaped for quotes and backslashes. The method does not attempt to pretty-print; callers can format the output if needed.
- Returns:
- a JSON string describing algorithms, capabilities, and key builders
-
toXml
Serializes the catalog to an XML document.The root element is
<cryptoCatalog>. Each algorithm becomes an<algorithm>element withidandnameattributes, plus nested sections for<capabilities>,<asymmetricKeyBuilders>, and<symmetricKeyBuilders>.Element text and attribute values are escaped for
&, <, >.- Returns:
- an XML string describing algorithms, capabilities, and key builders
-