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 Details

    • SignatureServiceImpl

      public SignatureServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api)
      Convenience constructor using the default OverwritePolicy.FAIL_IF_EXISTS policy.
    • SignatureServiceImpl

      public SignatureServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api, OverwritePolicy overwritePolicy)
  • Method Details

    • signFile

      public SignResult signFile(String kid, Path input, Path jwsOut) throws AnkaSecureSdkException
      Specified by:
      signFile in interface co.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.SignatureService
      Attached file sign with an explicit JWS serialization selection (PRD §60). A null serialization omits the field and lets the server choose the standards-correct representation.
      Specified by:
      signFile in interface co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Throws:
      AnkaSecureSdkException
    • verifySignature

      public VerifySignatureResult verifySignature(Path jwsFile) throws AnkaSecureSdkException
      Specified by:
      verifySignature in interface co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Throws:
      AnkaSecureSdkException
    • resignFile

      public ResignResult resignFile(String newKid, Path oldJws, Path newJws) throws AnkaSecureSdkException
      Specified by:
      resignFile in interface co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Throws:
      AnkaSecureSdkException
    • resignFile

      public ResignResult resignFile(String newKid, Path oldJws, Path newJws, JwsSerialization serialization) throws AnkaSecureSdkException
      Description copied from interface: co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Attached file re-sign with an explicit JWS serialization selection (PRD §60). A null serialization omits the field.
      Specified by:
      resignFile in interface co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Throws:
      AnkaSecureSdkException
    • signFileStream

      public SignResult signFileStream(String kid, Path input, Path sigOut) throws AnkaSecureSdkException
      Specified by:
      signFileStream in interface co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Throws:
      AnkaSecureSdkException
    • resignFileStream

      public ResignResult resignFileStream(Path oldJws, String newKid, Path input, Path newSigOut) throws AnkaSecureSdkException
      Description copied from interface: co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Re-sign a detached-payload JWS in streaming mode.
      The existing *General-JSON* header (containing the old kid) is supplied in oldJwsHeader. The payload itself is streamed from input.
      Specified by:
      resignFileStream in interface co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Parameters:
      oldJws - UTF-8 file that contains the original JWS header (General-JSON, detached payload)
      newKid - key identifier that must sign the refreshed JWS
      input - data whose signature is being replaced
      newSigOut - destination file that will receive the new signature
      Throws:
      AnkaSecureSdkException
    • signBytes

      public SignResult signBytes(String kid, byte[] data) throws AnkaSecureSdkException
      Sign an in-memory payload with a server-side **private** key.
      Specified by:
      signBytes in interface co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Parameters:
      kid - private-key ID in Anka Secure (must not be null)
      data - bytes to be signed (must not be null)
      Returns:
      SignResult containing the detached Compact JWS 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.SignatureService
      Signs an in-memory payload with an explicit JWS serialization selection (PRD §60). A null serialization omits the field and lets the server choose the standards-correct representation.
      Specified by:
      signBytes in interface co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Parameters:
      kid - private-key ID in Anka Secure (must not be null)
      data - bytes to be signed (must not be null)
      serialization - requested serialization, or null to defer to the server
      Returns:
      SignResult containing the JWS and metadata
      Throws:
      AnkaSecureSdkException - on validation or remote failure
    • verifySignatureBytes

      public VerifySignatureResult verifySignatureBytes(String jwsToken) throws AnkaSecureSdkException
      Verify a Compact JWS that is fully in memory.
      Specified by:
      verifySignatureBytes in interface co.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 oldJws) throws AnkaSecureSdkException
      Re-sign a Compact JWS switching to newKid.
      Specified by:
      resignBytes in interface co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Parameters:
      newKid - private-key ID that must generate the new signature
      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 oldJws, JwsSerialization serialization) throws AnkaSecureSdkException
      Description copied from interface: co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Re-signs a JWS with an explicit JWS serialization selection (PRD §60). A null serialization omits the field.
      Specified by:
      resignBytes in interface co.ankatech.ankasecure.sdk.internal.service.SignatureService
      Parameters:
      newKid - private-key ID that must generate the new signature
      oldJws - existing JWS (Compact or JWS-JSON, UTF-8)
      serialization - requested serialization, or null to defer to the server
      Returns:
      dual-key metadata plus the new token
      Throws:
      AnkaSecureSdkException - on validation or remote failure