Class KeyMetadata
This class provides a complete view of a key's identity, configuration, lifecycle,
and usage statistics. It is returned by the read-only key query operations
(listKeys / getKeyMetadata).
Key Type Detection:
- Simple key:
ktyis "ML-KEM", "ML-DSA", "RSA", "EC", "oct", etc., andcompositeModeisnull - Composite key:
ktyis the single coarse token "COMPOSITE" for every pairing;algnames the pairing andcompositeModenames the construction - Composite KEM:
compositeModeisCOMPOSITE_KEM_COMBINE - Composite Signature:
compositeModeisCOMPOSITE_SIGNATURE - Destroyed key (
getStatus()isdeleted_logical): no shape is reported.kty,algandcompositeModeare allnull, soisComposite(),isCompositeKem()andisCompositeSignature()answerfalsewhatever the destroyed key's shape was. Read the status first.
Destroyed keys (Deleted view)
The key list returns destroyed keys only when the status filter is deleted_logical
(new KeyFilters(null, null, null, "deleted_logical")); every other listing, and
KeyFilters.none(), holds only keys the tenant still has. A destroyed-key row is built from
the key identity alone. It carries getKid(), getUuid(), getStatus()
(deleted_logical), getCreatedAt() and getDeletedAt(). It reports no
key type, algorithm, composite mode, KDF, exportability, origin, restriction, expiry or usage:
each of those is null, never a default. getKeyOps() is an empty list on such a
row, because the generated client materialises an absent list as an empty one.
A kid can be taken again after its key is destroyed, so a destroyed-key row can share its kid
with a live key, and several destroyed-key rows can share one kid. getUuid() is the key's
own identity, never reused, and is the member that tells such rows apart.
Usage Examples
Check Key Type
KeyMetadata metadata = sdk.getKeyMetadata(kid);
if (metadata.isComposite()) {
System.out.println("Composite key: " + metadata.getKty());
if (metadata.isCompositeKem()) {
System.out.println("KDF used: " + metadata.getKdf());
}
} else {
System.out.println("Simple key: " + metadata.getKty());
}
Check Lifecycle Status
System.out.println("Status: " + metadata.getStatus());
System.out.println("Created: " + metadata.getCreatedAt());
System.out.println("Expires: " + metadata.getExpiresAt());
System.out.println("Usage: " + metadata.getUsageCount() + " / " + metadata.getMaxUsageLimit());
Lifecycle States
The getStatus() field carries the published key-status token. The vocabulary is
closed and is exactly the enum the crypto specification publishes for
KeySummaryResponse.status — the same token the ?status= filter of the key-list
endpoint accepts:
- active: Key is operational and can be used for cryptographic operations
- pending_rotation: Rotation is scheduled but has not executed yet
- rotated: Key material superseded by a newer version under the same kid
- expired: Key past
getExpiresAt()or its usage limit, cannot be used - revoked: Key explicitly revoked due to compromise or policy
- archived: Retained for compliance and audit only, read-only
- suspended: Temporarily blocked for incident investigation; reversible
- pending_destruction: In a mandatory cooling-off period before logical
deletion; reversible back to
archived - deleted_logical: Logically deleted and hidden from standard queries
A status token this SDK release does not know is reported as STATUS_UNKNOWN. It names
no lifecycle state: treat such a key as not usable, and upgrade the SDK to interpret it.
Thread Safety
Instances are immutable value objects safe to share across threads.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThegetStatus()token for a status the server returned that this SDK release does not know. -
Constructor Summary
ConstructorsConstructorDescriptionKeyMetadata(String kid, String uuid, String kty, CompositeMode compositeMode, String alg, String kdf, List<String> keyOps, Boolean exportable, KeyOrigin origin, Boolean restricted, String status, ZonedDateTime createdAt, ZonedDateTime expiresAt, ZonedDateTime softLimitExpiration, ZonedDateTime deletedAt, Integer usageCount, Integer softUsageLimit, Integer maxUsageLimit) Constructor for internal SDK use. -
Method Summary
Modifier and TypeMethodDescriptiongetAlg()Returns the algorithm identifier.Returns how a composite key's components are combined.Returns the key creation timestamp.Returns when the key was destroyed.Returns the hard expiration timestamp.Returns whether the key can be exported.getKdf()Returns the key derivation function for composite KEM keys.Returns the permitted key operations.getKid()Returns the key identifier (kid) the key is addressed by.getKty()Returns the key type.Returns the hard usage limit.Returns the key origin.Returns whether the key is restricted (legacy format).Returns the soft expiration (warning threshold) timestamp.Returns the soft usage limit (warning threshold).Returns the current lifecycle status, as the published key-status token.Returns the current usage counter.getUuid()Returns the key's own identity.booleanChecks if this is a composite key.booleanChecks if this is a composite KEM key.booleanChecks if this is a composite signature key.
-
Field Details
-
STATUS_UNKNOWN
ThegetStatus()token for a status the server returned that this SDK release does not know. Upgrade the SDK to interpret it. It is not a published token, soKeyFiltersrefuses it as a status filter.- See Also:
-
-
Constructor Details
-
KeyMetadata
public KeyMetadata(String kid, String uuid, String kty, CompositeMode compositeMode, String alg, String kdf, List<String> keyOps, Boolean exportable, KeyOrigin origin, Boolean restricted, String status, ZonedDateTime createdAt, ZonedDateTime expiresAt, ZonedDateTime softLimitExpiration, ZonedDateTime deletedAt, Integer usageCount, Integer softUsageLimit, Integer maxUsageLimit) Constructor for internal SDK use. Use mapper in KeyManagementServiceImpl.
-
-
Method Details
-
getKid
Returns the key identifier (kid) the key is addressed by.A kid can be taken again after its key is destroyed, so on a destroyed-key row (
deleted_logical) it does not identify the row on its own: usegetUuid().- Returns:
- key identifier (never
null)
-
getUuid
Returns the key's own identity.Assigned when the key is created, kept across every rotation of its kid, and never reused: a kid taken again after its key is destroyed belongs to a key with a new identity. It is the only member that tells apart rows sharing a kid: a live key and the destroyed-key row of a key that once held the same kid, or two destroyed-key rows of a kid reused twice.
- Returns:
- the key identity as a UUID string; the server states it on every row of the key list and on the key-metadata read
-
getKty
Returns the key type.Examples: "ML-KEM", "ML-DSA", "RSA", "EC", "oct", and the single coarse token "COMPOSITE" for every hybrid pairing. A composite key's construction is reported by
getCompositeMode()and its exact pairing bygetAlg().- Returns:
- key type, or
nullon a destroyed-key row (deleted_logical), which reports no shape
-
getCompositeMode
Returns how a composite key's components are combined.Every composite key publishes the coarse key type
COMPOSITE, so this value — notgetKty()— is what distinguishes a hybrid KEM from a hybrid signature. It isnullfor a simple key, where that absence means "not composite". It is alsonullon a destroyed-key row (deleted_logical), where it means "no shape reported", not "simple".- Returns:
- the composite construction, or
nullfor a simple key and for a destroyed-key row
-
getAlg
Returns the algorithm identifier.For simple keys: Single algorithm (e.g., "ML-KEM-768", "RSA-4096")
For composite keys: Combined algorithms (e.g., "X25519+ML-KEM-768", "Ed25519+ML-DSA-44")- Returns:
- algorithm identifier, or
nullon a destroyed-key row (deleted_logical)
-
getKdf
Returns the key derivation function for composite KEM keys.Only present when
getCompositeMode()isCOMPOSITE_KEM_COMBINE. Common values: "HKDF-SHA256", "HKDF-SHA512"- Returns:
- KDF identifier, or
nullif not a composite KEM key and on a destroyed-key row (deleted_logical)
-
getKeyOps
Returns the permitted key operations.Common values: "encrypt", "decrypt", "sign", "verify", "wrapKey", "unwrapKey"
- Returns:
- unmodifiable list of operations; an empty list on a destroyed-key row
(
deleted_logical), which states no operations (the generated client materialises the absent member as an empty list)
-
getExportable
Returns whether the key can be exported.- Returns:
trueif exportable,falseotherwise;nullon a destroyed-key row (deleted_logical), which has no exportability to report
-
getOrigin
Returns the key origin.- Returns:
- key origin (GENERATED, IMPORTED);
nullon a destroyed-key row (deleted_logical), which states no provenance
-
getRestricted
Returns whether the key is restricted (legacy format).- Returns:
trueif restricted,falseotherwise;nullon a destroyed-key row (deleted_logical)
-
getStatus
Returns the current lifecycle status, as the published key-status token.The vocabulary is closed and is exactly the
enumthe crypto specification publishes forKeySummaryResponse.status:active,pending_rotation,rotated,expired,revoked,archived,suspended,pending_destruction,deleted_logical. It is the same token the?status=filter of the key-list endpoint accepts, so a listed status can be passed back as a filter.deleted_logicalmarks a destroyed-key row, the one row that reports no shape, material or usage.- Returns:
- the published status token (never
null)
-
getCreatedAt
Returns the key creation timestamp.- Returns:
- creation timestamp (never
null)
-
getExpiresAt
Returns the hard expiration timestamp.- Returns:
- expiration timestamp, or
nullif no expiration is set and on a destroyed-key row (deleted_logical)
-
getSoftLimitExpiration
Returns the soft expiration (warning threshold) timestamp.- Returns:
- soft limit timestamp, or
nullif no soft limit is set and on a destroyed-key row (deleted_logical)
-
getDeletedAt
Returns when the key was destroyed.- Returns:
- destruction timestamp on a destroyed-key row (
deleted_logical);nullon every key the tenant still holds
-
getUsageCount
Returns the current usage counter.- Returns:
- usage count, or
nullon a destroyed-key row (deleted_logical)
-
getSoftUsageLimit
Returns the soft usage limit (warning threshold).- Returns:
- soft usage limit, or
nullif no soft limit is set and on a destroyed-key row (deleted_logical)
-
getMaxUsageLimit
Returns the hard usage limit.- Returns:
- maximum usage limit, or
nullif no limit is set and on a destroyed-key row (deleted_logical)
-
isComposite
public boolean isComposite()Checks if this is a composite key.A destroyed-key row (
getStatus()isdeleted_logical) reports no key type, so this answersfalsethere even when the destroyed key was composite:falseon such a row means "shape not reported", not "simple".- Returns:
trueif kty is the coarse composite tokenCOMPOSITE
-
isCompositeKem
public boolean isCompositeKem()Checks if this is a composite KEM key.Decided by
getCompositeMode(), never by the key type: every composite key publishes the same coarsekty, so a key-type comparison could only answer "composite", never "which construction". A destroyed-key row reports no construction, so this answersfalsethere (seeisComposite()).- Returns:
trueif the composite construction isCOMPOSITE_KEM_COMBINE
-
isCompositeSignature
public boolean isCompositeSignature()Checks if this is a composite signature key.Decided by
getCompositeMode(), for the same reason asisCompositeKem(), andfalseon a destroyed-key row for the same reason asisComposite().- Returns:
trueif the composite construction isCOMPOSITE_SIGNATURE
-