Class PTEID_SigningDeviceProxy

java.lang.Object
pt.gov.cartaodecidadao.PTEID_SigningDeviceProxy
All Implemented Interfaces:
PTEID_SigningDevice

public class PTEID_SigningDeviceProxy extends Object implements PTEID_SigningDevice
Interface class for objects with Signing capabilities.
Since:
3.8.0
  • Method Details

    • delete

      public void delete()
    • PTEID_SigningDevice_GetInterfaceCPtr

      public long PTEID_SigningDevice_GetInterfaceCPtr()
      Specified by:
      PTEID_SigningDevice_GetInterfaceCPtr in interface PTEID_SigningDevice
    • Sign

      public PTEID_ByteArray Sign(PTEID_ByteArray data, boolean signatureKey) throws PTEID_Exception
      Raw RSA signature with PKCS #1 padding.
      Specified by:
      Sign in interface PTEID_SigningDevice
      Parameters:
      data - holds the data to be signed, at most 32 bytes. This data should be hashed using sha256.
      signatureKey - whether to use the 'Signature key'. By default, it uses the 'Authentication private key'. To
      sign with the 'Signature private key' set the parameter signatureKey to true.
      Returns:
      A PTEID_ByteArray containing the signed data.
      Throws:
      PTEID_Exception
    • Sign

      public PTEID_ByteArray Sign(PTEID_ByteArray data) throws PTEID_Exception
      Raw RSA signature with PKCS #1 padding.
      Specified by:
      Sign in interface PTEID_SigningDevice
      Parameters:
      data - holds the data to be signed, at most 32 bytes. This data should be hashed using sha256.

      Returns:
      A PTEID_ByteArray containing the signed data.
      Throws:
      PTEID_Exception
    • SignSHA256

      public PTEID_ByteArray SignSHA256(PTEID_ByteArray data, boolean signatureKey) throws PTEID_Exception
      Deprecated.
      This method is now deprecated. Use PTEID_SigningDevice::Sign method instead, which already supports
      SHA256.
      Raw RSA signature with PKCS #1 padding (applied to a SHA256 hash).
      Specified by:
      SignSHA256 in interface PTEID_SigningDevice
      Parameters:
      data - holds the data to be signed, it should be 32 bytes.
      signatureKey - whether to use the 'Signature key'. By default, it uses the 'Authentication private key'. To
      sign with the 'Signature private key' set the parameter signatureKey to true.
      Returns:
      A PTEID_ByteArray containing the signed data.
      Throws:
      PTEID_Exception
    • SignSHA256

      public PTEID_ByteArray SignSHA256(PTEID_ByteArray data) throws PTEID_Exception
      Deprecated.
      This method is now deprecated. Use PTEID_SigningDevice::Sign method instead, which already supports
      SHA256.
      Raw RSA signature with PKCS #1 padding (applied to a SHA256 hash).
      Specified by:
      SignSHA256 in interface PTEID_SigningDevice
      Parameters:
      data - holds the data to be signed, it should be 32 bytes.

      Returns:
      A PTEID_ByteArray containing the signed data.
      Throws:
      PTEID_Exception
    • SignXades

      public PTEID_ByteArray SignXades(String output_path, String[] paths, long n_paths, PTEID_SignatureLevel level) throws PTEID_Exception
      Produce a XAdES Signature of the files indicated by the parameter paths and stores the results in one ASiC
      container in a zip format. The location of the resulting ASiC container is indicated by the parameter
      output_path.

      Specified by:
      SignXades in interface PTEID_SigningDevice
      Parameters:
      output_path - points to the resulting container
      paths - is an array of null-terminated strings representing absolute paths in
      the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA
      signature
      n_paths - is the number of elements in the paths array
      level - is an enum used to set the XAdES signature level/profile: XAdES-B (PTEID_LEVEL_BASIC), XAdES-T
      (PTEID_LEVEL_T), XAdES-LTA (PTEID_LEVEL_LTV). Note: Setting parameter level to PTEID_LEVEL_LT will throw
      PTEID_Exception(EIDMW_ERR_PARAM_BAD), as it is not supported yet.
      Throws:
      PTEID_Exception
    • SignXades

      public PTEID_ByteArray SignXades(String output_path, String[] paths, long n_paths) throws PTEID_Exception
      Produce a XAdES Signature of the files indicated by the parameter paths and stores the results in one ASiC
      container in a zip format. The location of the resulting ASiC container is indicated by the parameter
      output_path.

      Specified by:
      SignXades in interface PTEID_SigningDevice
      Parameters:
      output_path - points to the resulting container
      paths - is an array of null-terminated strings representing absolute paths in
      the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA
      signature
      n_paths - is the number of elements in the paths array
      Throws:
      PTEID_Exception
    • SignXadesT

      public PTEID_ByteArray SignXadesT(String output_path, String[] paths, long n_paths) throws PTEID_Exception
      Deprecated.
      use the SignXades function and set signature level with level (PTEID_SignatureLevel) parameter
      instead
      Produce a XAdES-T Signature of the files indicated by the parameter paths and stores the results in one ASiC
      container in a zip format. The location of the resulting ASiC container is indicated by the parameter
      output_path. If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file is a XAdES-B signature.

      Specified by:
      SignXadesT in interface PTEID_SigningDevice
      Parameters:
      output_path - points to the resulting container
      paths - is an array of null-terminated strings representing absolute paths in
      the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA
      signature
      n_paths - is the number of elements in the paths array
      Throws:
      PTEID_Exception
    • SignXadesA

      public PTEID_ByteArray SignXadesA(String output_path, String[] paths, long n_paths) throws PTEID_Exception
      Deprecated.
      use the SignXades function and set signature level with level (PTEID_SignatureLevel) parameter
      instead
      Produce a XAdES-LTA Signature of the files indicated by the parameter paths and stores the results in one ASiC
      container in a zip format. The location of the resulting ASiC container is indicated by the parameter
      output_path. If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file is a XAdES-B signature. If
      PTEID_Exception(EIDMW_LTV_ERROR) is thrown, the resulting file is a XAdES-LT or XAdES-LTA depending where the
      timestamping fails.

      Specified by:
      SignXadesA in interface PTEID_SigningDevice
      Parameters:
      output_path - points to the resulting container
      paths - is an array of null-terminated strings representing absolute paths in
      the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA
      signature
      n_paths - is the number of elements in the paths array
      Throws:
      PTEID_Exception
    • SignXadesIndividual

      public void SignXadesIndividual(String output_path, String[] paths, long n_paths) throws PTEID_Exception
      Produce XAdES-B Signatures of the files indicated by the parameter paths and stores each of the results in an
      individual ASiC container in a zip format.

      Specified by:
      SignXadesIndividual in interface PTEID_SigningDevice
      Parameters:
      output_path - directory of the created ASiC containers
      paths - is an array of null-terminated strings representing absolute paths in
      the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA
      signature
      n_paths - is the number of elements in the paths array
      Throws:
      PTEID_Exception
    • SignXadesTIndividual

      public void SignXadesTIndividual(String output_path, String[] paths, long n_paths) throws PTEID_Exception
      Produce XAdES-T Signatures of the files indicated by the parameter paths and stores each of the results in an
      individual ASiC container in a zip format. If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file
      is a XAdES-B signature.

      Specified by:
      SignXadesTIndividual in interface PTEID_SigningDevice
      Parameters:
      output_path - directory of the created ASiC containers
      paths - is an array of null-terminated strings representing absolute paths in
      the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA
      signature
      n_paths - is the number of elements in the paths array
      Throws:
      PTEID_Exception
    • SignXadesAIndividual

      public void SignXadesAIndividual(String output_path, String[] paths, long n_paths) throws PTEID_Exception
      Produce XAdES-A Signatures of the files indicated by the parameter paths and stores each of the results in an
      individual ASiC container in a zip format. If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file
      is a XAdES-B signature. If PTEID_Exception(EIDMW_LTV_ERROR) is thrown, the resulting file is a XAdES-LT or
      XAdES-LTA depending where the timestamping fails.

      Specified by:
      SignXadesAIndividual in interface PTEID_SigningDevice
      Parameters:
      output_path - directory of the created ASiC containers
      paths - is an array of null-terminated strings representing absolute paths in
      the local filesystem. Those files content (hashed with SHA-256 algorithm) will be the input data for the RSA
      signature
      n_paths - is the number of elements in the paths array
      Throws:
      PTEID_Exception
    • SignASiC

      public void SignASiC(String path, PTEID_SignatureLevel level)
      Specified by:
      SignASiC in interface PTEID_SigningDevice
    • SignASiC

      public void SignASiC(String path)
      Specified by:
      SignASiC in interface PTEID_SigningDevice
    • SignPDF

      public int SignPDF(PTEID_PDFSignature sig_handler, int page, int page_sector, boolean is_landscape, String location, String reason, String outfile_path) throws PTEID_Exception
      Deprecated.
      use the SignPDF function with location coordinates instead
      PDF Signature with location by page sector (the portrait A4 page is split into 18 cells: 6 lines and 3 columns)
      If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the resulting file is a PAdES-B signature.
      If PTEID_Exception(EIDMW_LTV_ERROR) is thrown, the resulting file is a PAdES-LT or PAdES-LTA depending where the
      timestamping fails.

      Specified by:
      SignPDF in interface PTEID_SigningDevice
      Parameters:
      sig_handler - : this defines the input file and some signature options
      page - : in case of visible signature it defines the page where the signature will appear
      page_sector - : position in the signature grid, between 1 to 18 for Portrait documents and 1 to 20 for
      Landscape ones
      is_landscape - : is unused parameter, the SDK now detects document orientation automatically
      location - : Signature metadata field
      reason - : Signature metadata field
      outfile_path - : Native Filesystem path of the ouput file
      Throws:
      PTEID_Exception
    • SignPDF

      public int SignPDF(PTEID_PDFSignature sig_handler, int page, double coord_x, double coord_y, String location, String reason, String outfile_path) throws PTEID_Exception
      PDF Signature with location by coordinates (expressed in percentage of page height/width). The coordinate system
      has its origin in the top left corner of the page If PTEID_Exception(EIDMW_TIMESTAMP_ERROR) is thrown, the
      resulting file is a PAdES-B signature. If PTEID_Exception(EIDMW_LTV_ERROR) is thrown, the resulting file is a
      PAdES-LT or PAdES-LTA depending where the timestamping fails.

      Specified by:
      SignPDF in interface PTEID_SigningDevice
      Parameters:
      sig_handler - : this defines the input file and some signature options
      page - : in case of visible signature it defines the page where the signature will appear
      coord_x - : X coordinate of the signature location (percentage of page width)
      coord_y - : Y coordinate of the signature location (percentage of page height)
      location - : Location field in the added signature metadata
      reason - : Signature metadata field
      outfile_path - : Native Filesystem path of the ouput file
      Throws:
      PTEID_Exception
    • getCertificates

      public PTEID_Certificates getCertificates() throws PTEID_Exception
      Deprecated.
      Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain
      manually.
      Specified by:
      getCertificates in interface PTEID_SigningDevice
      Throws:
      PTEID_Exception
    • getCert

      public PTEID_Certificate getCert(PTEID_CertifType type) throws PTEID_Exception
      Deprecated.
      Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain
      manually.
      Specified by:
      getCert in interface PTEID_SigningDevice
      Throws:
      PTEID_Exception
    • getRoot

      public PTEID_Certificate getRoot() throws PTEID_Exception
      Deprecated.
      Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain
      manually.
      Specified by:
      getRoot in interface PTEID_SigningDevice
      Throws:
      PTEID_Exception
    • getCA

      public PTEID_Certificate getCA() throws PTEID_Exception
      Deprecated.
      Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain
      manually.
      Specified by:
      getCA in interface PTEID_SigningDevice
      Throws:
      PTEID_Exception
    • getSignature

      public PTEID_Certificate getSignature() throws PTEID_Exception
      Deprecated.
      Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain
      manually.
      Specified by:
      getSignature in interface PTEID_SigningDevice
      Throws:
      PTEID_Exception
    • getAuthentication

      public PTEID_Certificate getAuthentication() throws PTEID_Exception
      Deprecated.
      Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain
      manually.
      Specified by:
      getAuthentication in interface PTEID_SigningDevice
      Throws:
      PTEID_Exception
    • getDeviceType

      public PTEID_SigningDeviceType getDeviceType()
      Get type of SigningDeviceType.
      Specified by:
      getDeviceType in interface PTEID_SigningDevice