Class SignatureServiceImpl
java.lang.Object
co.ankatech.ankasecure.sdk.internal.service.impl.SignatureServiceImpl
- All Implemented Interfaces:
co.ankatech.ankasecure.sdk.internal.service.SignatureService
public final class SignatureServiceImpl
extends Object
implements co.ankatech.ankasecure.sdk.internal.service.SignatureService
Thread-safe implementation of
SignatureService.-
Constructor Summary
ConstructorsConstructorDescriptionSignatureServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api) Convenience constructor using the defaultOverwritePolicy.FAIL_IF_EXISTSpolicy.SignatureServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api, OverwritePolicy overwritePolicy) -
Method Summary
Modifier and TypeMethodDescriptionresignBytes(String newKid, String sourceKid, String oldJws) Re-sign a Compact JWS switching tonewKid.resignBytes(String newKid, String sourceKid, String oldJws, JwsSerialization serialization) Re-signs a JWS with an explicit JWS serialization selection.resignFile(String newKid, String sourceKid, Path oldJws, Path newJws) resignFile(String newKid, String sourceKid, Path oldJws, Path newJws, JwsSerialization serialization) Attached file re-sign with an explicit JWS serialization selection.Re-sign a detached-payload JWS in streaming mode.
The existing detached JWS (flattened JWS JSON whose protected header names the oldkid, with"b64": false) is supplied inoldJwsHeader.Sign an in-memory payload with a server-side **private** key.signBytes(String kid, byte[] data, JwsSerialization serialization) Signs an in-memory payload with an explicit JWS serialization selection.signFile(String kid, Path input, Path jwsOut, JwsSerialization serialization) Attached file sign with an explicit JWS serialization selection.signFileStream(String kid, Path input, Path sigOut) verifySignature(Path jwsFile) verifySignatureBytes(String jwsToken) Verify a Compact JWS that is fully in memory.
-
Constructor Details
-
SignatureServiceImpl
public SignatureServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api) Convenience constructor using the defaultOverwritePolicy.FAIL_IF_EXISTSpolicy. -
SignatureServiceImpl
public SignatureServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api, OverwritePolicy overwritePolicy)
-
-
Method Details
-
signFile
- Specified by:
signFilein interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureService- Throws:
AnkaSecureSdkException
-
signFile
public SignResult signFile(String kid, Path input, Path jwsOut, JwsSerialization serialization) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.SignatureServiceAttached file sign with an explicit JWS serialization selection. Anullserialization omits the field and lets the server choose the standards-correct representation.- Specified by:
signFilein interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureService- Throws:
AnkaSecureSdkException
-
verifySignature
- Specified by:
verifySignaturein interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureService- Throws:
AnkaSecureSdkException
-
resignFile
public ResignResult resignFile(String newKid, String sourceKid, Path oldJws, Path newJws) throws AnkaSecureSdkException - Specified by:
resignFilein interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureServicesourceKid- the signer whose signature is replaced, ornullwhen the protected header names one key (required by the server for a JWS signed by several keys or naming none)- Throws:
AnkaSecureSdkException
-
resignFile
public ResignResult resignFile(String newKid, String sourceKid, Path oldJws, Path newJws, JwsSerialization serialization) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.SignatureServiceAttached file re-sign with an explicit JWS serialization selection. Anullserialization omits the field.- Specified by:
resignFilein interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureServicesourceKid- the signer whose signature is replaced, ornullwhen the protected header names one key (required by the server for a JWS signed by several keys or naming none)- Throws:
AnkaSecureSdkException
-
signFileStream
- Specified by:
signFileStreamin interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureService- Throws:
AnkaSecureSdkException
-
resignFileStream
public ResignResult resignFileStream(Path oldJws, String newKid, String sourceKid, Path input, Path newSigOut) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.SignatureServiceRe-sign a detached-payload JWS in streaming mode.
The existing detached JWS (flattened JWS JSON whose protected header names the oldkid, with"b64": false) is supplied inoldJwsHeader. The payload itself is streamed frominput.- Specified by:
resignFileStreamin interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureService- Parameters:
oldJws- UTF-8 file that contains the original detached JWS (flattened JWS JSON, detached payload)newKid- key identifier that must sign the refreshed JWSsourceKid- the signer whose signature is replaced, ornullwhen the protected header names one key (required by the server for a JWS signed by several keys or naming none)input- data whose signature is being replacednewSigOut- destination file that will receive the new signature- Throws:
AnkaSecureSdkException
-
signBytes
Sign an in-memory payload with a server-side **private** key.- Specified by:
signBytesin interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureService- Parameters:
kid- private-key ID in ANKASecure (must not benull)data- bytes to be signed (must not benull)- Returns:
SignResultcontaining the attached JWS (payload embedded) and metadata- Throws:
AnkaSecureSdkException- on validation or remote failure
-
signBytes
public SignResult signBytes(String kid, byte[] data, JwsSerialization serialization) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.SignatureServiceSigns an in-memory payload with an explicit JWS serialization selection. Anullserialization omits the field and lets the server choose the standards-correct representation.- Specified by:
signBytesin interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureService- Parameters:
kid- private-key ID in ANKASecure (must not benull)data- bytes to be signed (must not benull)serialization- requested serialization, ornullto defer to the server- Returns:
SignResultcontaining the JWS and metadata- Throws:
AnkaSecureSdkException- on validation or remote failure
-
verifySignatureBytes
Verify a Compact JWS that is fully in memory.- Specified by:
verifySignatureBytesin interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureService- Parameters:
jwsToken- textual Compact JWS (UTF-8)- Returns:
- outcome, metadata, and Base64 payload
- Throws:
AnkaSecureSdkException- on validation or remote failure
-
resignBytes
public ResignResult resignBytes(String newKid, String sourceKid, String oldJws) throws AnkaSecureSdkException Re-sign a Compact JWS switching tonewKid.- Specified by:
resignBytesin interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureService- Parameters:
newKid- private-key ID that must generate the new signaturesourceKid- the signer whose signature is replaced, ornullwhen the protected header names one key (required by the server for a JWS signed by several keys or naming none)oldJws- existing Compact JWS (UTF-8)- Returns:
- dual-key metadata plus the new token
- Throws:
AnkaSecureSdkException- on validation or remote failure
-
resignBytes
public ResignResult resignBytes(String newKid, String sourceKid, String oldJws, JwsSerialization serialization) throws AnkaSecureSdkException Description copied from interface:co.ankatech.ankasecure.sdk.internal.service.SignatureServiceRe-signs a JWS with an explicit JWS serialization selection. Anullserialization omits the field.- Specified by:
resignBytesin interfaceco.ankatech.ankasecure.sdk.internal.service.SignatureService- Parameters:
newKid- private-key ID that must generate the new signaturesourceKid- the signer whose signature is replaced, ornullwhen the protected header names one key (required by the server for a JWS signed by several keys or naming none)oldJws- existing JWS (Compact or JWS-JSON, UTF-8)serialization- requested serialization, ornullto defer to the server- Returns:
- dual-key metadata plus the new token
- Throws:
AnkaSecureSdkException- on validation or remote failure
-