Class CombinedOperations
java.lang.Object
co.ankatech.ankasecure.sdk.operations.CombinedOperations
Combined cryptographic operations facade.
Public facade for combined operations (re-encryption, re-signature,
sign-then-encrypt, decrypt-then-verify, and utility operations with external keys).
All methods are exposed via AuthenticatedSdk.
Stateful signing keys
The operations that produce a signature — resign* (with the new key) and
signThenEncrypt* (with the signing key) — can be refused for a stateful
hash-based key (XMSS, XMSS^MT, LMS/HSS) with
SdkErrorCode.STATEFUL_KEY_EXHAUSTED (rotate the
key; do not retry) or SdkErrorCode.STATEFUL_KEY_BUSY
(retry after
AnkaSecureSdkException.getRetryAfterSeconds()),
decided before any output exists. A streaming re-sign reserves the one-time signature before it
reads the request body, so a request then refused for its body still spends one.
-
Constructor Summary
ConstructorsConstructorDescriptionCombinedOperations(InternalServiceFactory svc, TokenSource tokenSource, BooleanSupplier timingMetricsEnabled, org.slf4j.Logger userLogger) -
Method Summary
Modifier and TypeMethodDescriptiondecryptThenVerify(String recipientKid, String jweToken) decryptThenVerifyFileCompact(String recipientKid, Path input, Path output) decryptThenVerifyFileStream(String recipientKid, Path input, Path output) reencryptFileCompact(String newKid, String sourceKid, Path input, Path output) reencryptFileStream(String newKid, String sourceKid, Path input, Path output) resign(String newKid, String sourceKid, String jws, JwsSerialization serialization) Re-signs a JWS with an explicit JWS serialization selection.resignFileCompact(String newKid, String sourceKid, Path input, Path output) resignFileCompact(String newKid, String sourceKid, Path input, Path output, JwsSerialization serialization) Re-signs a file with an explicit JWS serialization selection.signThenEncrypt(String signKid, String encryptKid, byte[] data) signThenEncrypt(String signKid, String encryptKid, byte[] data, JwsSerialization serialization) Signs then encrypts with an explicit inner-JWS serialization selection.signThenEncryptFileCompact(String signKid, String encryptKid, Path input, Path output) signThenEncryptFileCompact(String signKid, String encryptKid, Path input, Path output, JwsSerialization serialization) Signs a file then encrypts it with an explicit inner-JWS serialization selection.signThenEncryptFileStream(String signKid, String encryptKid, Path input, Path output) verifySignatureUtilityStream(String kty, String alg, String publicKeyB64, String signatureB64, Path dataFile)
-
Constructor Details
-
CombinedOperations
public CombinedOperations(InternalServiceFactory svc, TokenSource tokenSource, BooleanSupplier timingMetricsEnabled, org.slf4j.Logger userLogger)
-
-
Method Details
-
reencrypt
public ReencryptResult reencrypt(String newKid, String sourceKid, String jweToken) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
reencryptFileCompact
public ReencryptResult reencryptFileCompact(String newKid, String sourceKid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
reencryptFileStream
public ReencryptResult reencryptFileStream(String newKid, String sourceKid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
encryptFileUtilityStream
public EncryptResult encryptFileUtilityStream(String kty, String alg, String publicKeyB64, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
verifySignatureUtilityStream
public VerifySignatureResult verifySignatureUtilityStream(String kty, String alg, String publicKeyB64, String signatureB64, Path dataFile) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
resign
public ResignResult resign(String newKid, String sourceKid, String jws) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
resign
public ResignResult resign(String newKid, String sourceKid, String jws, JwsSerialization serialization) throws AnkaSecureSdkException Re-signs a JWS with an explicit JWS serialization selection. Ergonomic overload ofresign(String, String, String); anullserializationdefers to the server.- Parameters:
newKid- destination key identifier; must not benullsourceKid- the signer whose signature is replaced, ornullwhen the protected header names one keyjws- the JWS to re-sign (compact or JWS-JSON); must not benullserialization- requested serialization, ornullto let the server choose- Returns:
- re-signature result; never
null - Throws:
AnkaSecureSdkException- on error, including HTTP 400 when COMPACT is requested but the deployment mandates a qualified timestampNullPointerException- ifnewKidorjwsisnull
-
resignFileCompact
public ResignResult resignFileCompact(String newKid, String sourceKid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
resignFileCompact
public ResignResult resignFileCompact(String newKid, String sourceKid, Path input, Path output, JwsSerialization serialization) throws AnkaSecureSdkException Re-signs a file with an explicit JWS serialization selection. Ergonomic overload ofresignFileCompact(String, String, Path, Path); anullserializationdefers to the server. When the server mandates a qualified timestamp, the written output is a JWS-JSON artifact carrying the JAdESsigTst.- Parameters:
newKid- destination key identifier; must not benullsourceKid- the signer whose signature is replaced, ornullwhen the protected header names one keyinput- input JWS file (compact or JWS-JSON); must not benulloutput- output file; must not benullserialization- requested serialization, ornullto let the server choose- Returns:
- re-signature result; never
null - Throws:
AnkaSecureSdkException- on error, including HTTP 400 when COMPACT is requested but the deployment mandates a qualified timestampNullPointerException- ifnewKid,input, oroutputisnull
-
resignFileStream
public ResignResult resignFileStream(Path oldJwsHeader, String newKid, String sourceKid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
signThenEncrypt
public SignEncryptResult signThenEncrypt(String signKid, String encryptKid, byte[] data) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
signThenEncrypt
public SignEncryptResult signThenEncrypt(String signKid, String encryptKid, byte[] data, JwsSerialization serialization) throws AnkaSecureSdkException Signs then encrypts with an explicit inner-JWS serialization selection. Ergonomic overload ofsignThenEncrypt(String, String, byte[]); anullserializationdefers to the server. Governs only the inner JWS representation and never changes the outer JWE.- Parameters:
signKid- private key identifier for signing; must not benullencryptKid- public key identifier for encryption; must not benulldata- plaintext bytes to sign and encrypt; must not benullserialization- requested inner-JWS serialization, ornullto defer- Returns:
- combined sign-encrypt result; never
null - Throws:
AnkaSecureSdkException- on error, including HTTP 400 (before any signing or encryption) when COMPACT is requested but the deployment mandates a qualified timestampNullPointerException- if any ofsignKid,encryptKid, ordataisnull
-
decryptThenVerify
public DecryptVerifyResult decryptThenVerify(String recipientKid, String jweToken) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
signThenEncryptFileCompact
public SignEncryptResult signThenEncryptFileCompact(String signKid, String encryptKid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
signThenEncryptFileCompact
public SignEncryptResult signThenEncryptFileCompact(String signKid, String encryptKid, Path input, Path output, JwsSerialization serialization) throws AnkaSecureSdkException Signs a file then encrypts it with an explicit inner-JWS serialization selection. Ergonomic overload ofsignThenEncryptFileCompact(String, String, Path, Path); anullserializationdefers to the server.- Parameters:
signKid- private key identifier for signing; must not benullencryptKid- public key identifier for encryption; must not benullinput- input file; must not benulloutput- output file; must not benullserialization- requested inner-JWS serialization, ornullto defer- Returns:
- combined sign-encrypt result; never
null - Throws:
AnkaSecureSdkException- on error, including HTTP 400 (before any signing or encryption) when COMPACT is requested but the deployment mandates a qualified timestampNullPointerException- if any argument isnull
-
decryptThenVerifyFileCompact
public DecryptVerifyResult decryptThenVerifyFileCompact(String recipientKid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
signThenEncryptFileStream
public SignEncryptResult signThenEncryptFileStream(String signKid, String encryptKid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
decryptThenVerifyFileStream
public DecryptVerifyResult decryptThenVerifyFileStream(String recipientKid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-