Class CombinedOperationsServiceImpl
- All Implemented Interfaces:
co.ankatech.ankasecure.sdk.internal.service.CombinedOperationsService
CombinedOperationsService.
Delegates all operations to the AnkaSecure REST API via OpenAPI client.
-
Constructor Summary
ConstructorsConstructorDescriptionCombinedOperationsServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api) Convenience constructor using the defaultOverwritePolicy.FAIL_IF_EXISTSpolicy.CombinedOperationsServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api, OverwritePolicy overwritePolicy) Constructor with dependency injection. -
Method Summary
Modifier and TypeMethodDescriptiondecryptThenVerify(String jweToken) Decrypts JWE token then verifies the inner JWS signature.decryptThenVerifyFile(Path input, Path output) Decrypts file then verifies signature (bulk/compact mode).decryptThenVerifyFileStream(Path input, Path output) Decrypts a nested JWE(JWS) file then verifies the inner signature (streaming mode for large files).signThenEncrypt(String signKid, String encryptKid, byte[] data) Signs data with signing key then encrypts the JWS result with encryption key.signThenEncrypt(String signKid, String encryptKid, byte[] data, JwsSerialization serialization) Sign-then-encrypt with an explicit inner-JWS serialization selection (PRD §60).signThenEncryptFile(String signKid, String encryptKid, Path input, Path output) Signs file content then encrypts result (bulk/compact mode).signThenEncryptFile(String signKid, String encryptKid, Path input, Path output, JwsSerialization serialization) Sign-then-encrypt a file with an explicit inner-JWS serialization selection (PRD §60).signThenEncryptFileStream(String signKid, String encryptKid, Path input, Path output) Signs file content then encrypts result (streaming mode for large files).
-
Constructor Details
-
CombinedOperationsServiceImpl
public CombinedOperationsServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api) Convenience constructor using the defaultOverwritePolicy.FAIL_IF_EXISTSpolicy.- Parameters:
api- OpenAPI client for REST API calls
-
CombinedOperationsServiceImpl
public CombinedOperationsServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api, OverwritePolicy overwritePolicy) Constructor with dependency injection.- Parameters:
api- OpenAPI client for REST API callsoverwritePolicy- how an existing output destination is handled at promotion time
-
-
Method Details
-
signThenEncrypt
public SignEncryptResult signThenEncrypt(String signKid, String encryptKid, byte[] data) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.CombinedOperationsServiceSigns data with signing key then encrypts the JWS result with encryption key.Produces a nested JWE(JWS) token structure: the plaintext is first signed (creating a JWS), then the JWS is encrypted (creating a JWE containing the JWS).
Use case: When you need both authenticity (signature) and confidentiality (encryption) in a single atomic operation.
- Specified by:
signThenEncryptin interfaceco.ankatech.ankasecure.sdk.internal.service.CombinedOperationsService- Parameters:
signKid- private key identifier for signingencryptKid- public key identifier for encryptiondata- plaintext bytes to sign and encrypt- Returns:
- result containing nested JWE(JWS) token and separated metadata
- Throws:
AnkaSecureSdkException- if signing or encryption fails, or if keys not found
-
signThenEncrypt
public SignEncryptResult signThenEncrypt(String signKid, String encryptKid, byte[] data, JwsSerialization serialization) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.CombinedOperationsServiceSign-then-encrypt with an explicit inner-JWS serialization selection (PRD §60). Anullserialization omits the field and lets the server choose the standards-correct representation of the inner JWS.- Specified by:
signThenEncryptin interfaceco.ankatech.ankasecure.sdk.internal.service.CombinedOperationsService- Parameters:
signKid- private key identifier for signingencryptKid- public key identifier for encryptiondata- plaintext bytes to sign and encryptserialization- requested inner-JWS serialization, ornullto defer- Returns:
- result containing nested JWE(JWS) token and separated metadata
- Throws:
AnkaSecureSdkException- if signing or encryption fails, or if keys not found
-
decryptThenVerify
Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.CombinedOperationsServiceDecrypts JWE token then verifies the inner JWS signature.Reverses the sign-encrypt operation: first decrypts the JWE to extract the JWS, then verifies the JWS signature and extracts the plaintext. Key identifiers are automatically extracted from JWE and JWS headers.
Important: This method will NOT fail if signature verification fails. Check
result.isSignatureValid()to confirm authenticity.- Specified by:
decryptThenVerifyin interfaceco.ankatech.ankasecure.sdk.internal.service.CombinedOperationsService- Parameters:
jweToken- nested JWE(JWS) token with kid claims in headers- Returns:
- result containing plaintext, verification status, and metadata
- Throws:
AnkaSecureSdkException- if decryption fails or token is malformed
-
signThenEncryptFile
public SignEncryptResult signThenEncryptFile(String signKid, String encryptKid, Path input, Path output) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.CombinedOperationsServiceSigns file content then encrypts result (bulk/compact mode).Reads entire file into memory, signs it, encrypts the signature, and writes the nested JWE(JWS) token to output file.
Size limit: Use streaming variant for files ≥100MB.
- Specified by:
signThenEncryptFilein interfaceco.ankatech.ankasecure.sdk.internal.service.CombinedOperationsService- Parameters:
signKid- private key identifier for signingencryptKid- public key identifier for encryptioninput- input file to read plaintext fromoutput- output file to write nested JWE(JWS) token to- Returns:
- result containing token location and separated metadata
- Throws:
AnkaSecureSdkException- if signing, encryption, or I/O fails
-
signThenEncryptFile
public SignEncryptResult signThenEncryptFile(String signKid, String encryptKid, Path input, Path output, JwsSerialization serialization) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.CombinedOperationsServiceSign-then-encrypt a file with an explicit inner-JWS serialization selection (PRD §60). Anullserialization omits the field.- Specified by:
signThenEncryptFilein interfaceco.ankatech.ankasecure.sdk.internal.service.CombinedOperationsService- Parameters:
signKid- private key identifier for signingencryptKid- public key identifier for encryptioninput- input file to read plaintext fromoutput- output file to write nested JWE(JWS) token toserialization- requested inner-JWS serialization, ornullto defer- Returns:
- result containing token location and separated metadata
- Throws:
AnkaSecureSdkException- if signing, encryption, or I/O fails
-
decryptThenVerifyFile
public DecryptVerifyResult decryptThenVerifyFile(Path input, Path output) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.CombinedOperationsServiceDecrypts file then verifies signature (bulk/compact mode).Reads nested JWE(JWS) token from input file, decrypts it, verifies signature, and writes plaintext to output file. Key identifiers are automatically extracted from token headers.
- Specified by:
decryptThenVerifyFilein interfaceco.ankatech.ankasecure.sdk.internal.service.CombinedOperationsService- Parameters:
input- input file containing nested JWE(JWS) token with kid claimsoutput- output file to write plaintext to- Returns:
- result containing plaintext location, verification status, and metadata
- Throws:
AnkaSecureSdkException- if decryption or I/O fails
-
signThenEncryptFileStream
public SignEncryptResult signThenEncryptFileStream(String signKid, String encryptKid, Path input, Path output) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.CombinedOperationsServiceSigns file content then encrypts result (streaming mode for large files).Uses multipart HTTP streaming to process the file in bounded memory so the inner signature is carried ENCRYPTED. Suitable for files ≥100MB. The response is the nested JWE(JWS) ciphertext, written to
outputvia the unified sidecar contract (PRODUCER — plain sidecar copy, no end-of-stream verdict); an existing destination is governed by the SDK'sOverwritePolicy.- Specified by:
signThenEncryptFileStreamin interfaceco.ankatech.ankasecure.sdk.internal.service.CombinedOperationsService- Parameters:
signKid- private key identifier for signing (inner JWS)encryptKid- public key identifier for encryption (outer JWE)input- input file to streamoutput- output file to write the nested JWE(JWS) artifact to- Returns:
- result containing the outer-JWE (encrypt) metadata; the artifact is the
outputfile (streaming —getJweToken()isnull) - Throws:
AnkaSecureSdkException- if signing, encryption, or streaming fails
-
decryptThenVerifyFileStream
public DecryptVerifyResult decryptThenVerifyFileStream(Path input, Path output) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.CombinedOperationsServiceDecrypts a nested JWE(JWS) file then verifies the inner signature (streaming mode for large files).Uses multipart HTTP streaming. The server returns a TWO-verdict trailing part carrying BOTH the outer AES-GCM tag result and the inner JWS signature result; the SDK quarantines the plaintext to a sidecar and promotes it to
outputONLY when the overall verdict is VALID (fail-closed). An INVALID or absent verdict discards the output and raises a typedStreamIntegrityException— no file is written.- Specified by:
decryptThenVerifyFileStreamin interfaceco.ankatech.ankasecure.sdk.internal.service.CombinedOperationsService- Parameters:
input- nested JWE(JWS) streaming artifact (the output ofsignThenEncryptFileStream)output- destination for the recovered plaintext- Returns:
- result with the recovered plaintext location, verification status, and the §60 informational qualified timestamp (which never affects validity)
- Throws:
AnkaSecureSdkException- if decryption or I/O failsStreamIntegrityException- if the integrity verdict is INVALID or absent
-