Package co.ankatech.ankasecure.sdk.model
Class ResignResult
java.lang.Object
co.ankatech.ankasecure.sdk.model.ResignResult
Result of a re-signature
operation.
Contains the new compact JWS token produced by server-side re-signature from one key to another, along with comprehensive metadata for both the old verification key and the new signing key. The signed payload is never exposed to the client during this operation.
Use Cases
- Signing key rotation without re-generating documents
- Migrating signed data to stronger signature algorithms
- Compliance-driven periodic key rotation
- Upgrading from classical to post-quantum signatures
JWS Token Structure
The getJwsToken() returns a compact JWS (RFC 7515) containing
three Base64URL segments:
BASE64URL(Header).BASE64URL(Payload).BASE64URL(Signature)
Thread Safety
Instances are effectively immutable after construction. All setters are for internal SDK use during deserialization. Once returned from SDK methods, instances are safe to share across threads.
Example
// Re-sign from RSA to ML-DSA
ResignResult result = sdk.resign("new-ml-dsa-key", oldJwsToken);
System.out.println("Re-signature complete");
System.out.println("Old signature: " + result.getOldKeyRequested() +
" (" + result.getOldKeyAlgorithmUsed() + ")");
System.out.println("New signature: " + result.getNewKeyRequested() +
" (" + result.getNewKeyAlgorithmUsed() + ")");
System.out.println("Material versions: " + result.getSourceMaterialVersion() +
" -> " + result.getTargetMaterialVersion());
// New JWS token ready for distribution
String newJws = result.getJwsToken();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the new compact JWS token after re-signing.Returns the algorithm used for signing.Returns the key identifier originally requested for signing.Returns the algorithm used for verification.Returns the key identifier originally requested for verification.Returns the key-material version that verified the original signature under the source Stable KID.Returns the PRIMARY key-material version that signed the new payload under the target Stable KID.Returns non-fatal warnings encountered during the re-signing operation.
-
Constructor Details
-
ResignResult
public ResignResult()
-
-
Method Details
-
getJwsToken
Returns the new compact JWS token after re-signing.- Returns:
- the compact JWS string (three Base64URL segments); never
null
-
getOldKeyRequested
Returns the key identifier originally requested for verification.- Returns:
- non-null old kid
-
getSourceMaterialVersion
Returns the key-material version that verified the original signature under the source Stable KID.- Returns:
- source material version;
nullwhen not resolvable — never 0
-
getOldKeyAlgorithmUsed
Returns the algorithm used for verification.- Returns:
- non-null algorithm identifier
-
getNewKeyRequested
Returns the key identifier originally requested for signing.- Returns:
- non-null new kid
-
getTargetMaterialVersion
Returns the PRIMARY key-material version that signed the new payload under the target Stable KID.- Returns:
- target material version;
nullwhen not resolvable — never 0
-
getNewKeyAlgorithmUsed
Returns the algorithm used for signing.- Returns:
- non-null algorithm identifier
-
getWarnings
Returns non-fatal warnings encountered during the re-signing operation.Warnings are type-safe instances that may relate to either the old verification key or the new signing key. Use pattern matching for programmatic handling:
ResignResult result = sdk.resign("new-signing-key", oldJwsToken); if (result.getWarnings() != null && !result.getWarnings().isEmpty()) { for (CryptoWarning warning : result.getWarnings()) { switch (warning) { case KeyExpirationWarning kew -> { logger.warn("Key expiring in {} days - Old: {}, New: {}", kew.daysRemaining(), result.getOldKeyRequested(), result.getNewKeyRequested()); if (kew.severity() == WarningSeverity.CRITICAL) { rotateSigningKey(result.getNewKeyRequested()); } } case UsageLimitWarning ulw when ulw.invocationsRemaining() <= 100 -> alertOps("Signing key usage critical: " + ulw.recommendedAction()); case GenericWarning gw -> logger.info("Re-signing warning: {}", gw.rawMessage()); } } }Common warning types:
KeyExpirationWarning: Old or new key approaching expirationUsageLimitWarning: Signing key usage limits approachingGenericWarning: Algorithm deprecation, rotation notices
- Returns:
- unmodifiable list of warnings (null if no warnings, never empty if non-null)
-