Portuguese eID Middleware SDK  Version: 3.12.0
eIDMW::PTEID_CMDSignatureClient Class Reference

#include <eidlib.h>

Public Member Functions

PTEIDSDK_API PTEID_CMDSignatureClient ()
 
virtual PTEIDSDK_API ~PTEID_CMDSignatureClient ()
 
PTEIDSDK_API void setMobileNumberCaching (bool enabled)
 
virtual PTEIDSDK_API PTEID_ByteArray Sign (const PTEID_ByteArray &data, bool signatureKey=false) override
 
virtual PTEIDSDK_API PTEID_ByteArray SignSHA256 (const PTEID_ByteArray &data, bool signatureKey=false) override
 
virtual PTEIDSDK_API PTEID_ByteArray SignXades (const char *output_path, const char *const *paths, unsigned int n_paths, PTEID_SignatureLevel level=PTEID_LEVEL_BASIC) override
 
virtual PTEIDSDK_API PTEID_ByteArray SignXadesT (const char *output_path, const char *const *paths, unsigned int n_paths) override
 
virtual PTEIDSDK_API PTEID_ByteArray SignXadesA (const char *output_path, const char *const *paths, unsigned int n_paths) override
 
virtual PTEIDSDK_API void SignXadesIndividual (const char *output_path, const char *const *paths, unsigned int n_paths) override
 
virtual PTEIDSDK_API void SignXadesTIndividual (const char *output_path, const char *const *paths, unsigned int n_paths) override
 
virtual PTEIDSDK_API void SignXadesAIndividual (const char *output_path, const char *const *paths, unsigned int n_paths) override
 
virtual PTEIDSDK_API int SignPDF (PTEID_PDFSignature &sig_handler, int page, int page_sector, bool is_landscape, const char *location, const char *reason, const char *outfile_path) override
 
virtual PTEIDSDK_API int SignPDF (PTEID_PDFSignature &sig_handler, int page, double coord_x, double coord_y, const char *location, const char *reason, const char *outfile_path) override
 
virtual PTEIDSDK_API PTEID_CertificatesgetCertificates () override
 
virtual PTEIDSDK_API PTEID_CertificategetCert (PTEID_CertifType type) override
 
virtual PTEIDSDK_API PTEID_CertificategetRoot () override
 
virtual PTEIDSDK_API PTEID_CertificategetCA () override
 
virtual PTEIDSDK_API PTEID_CertificategetSignature () override
 
virtual PTEIDSDK_API PTEID_CertificategetAuthentication () override
 
virtual PTEIDSDK_API PTEID_SigningDeviceType getDeviceType () override
 
- Public Member Functions inherited from eIDMW::PTEID_Object
virtual PTEIDSDK_API ~PTEID_Object ()=0
 
NOEXPORT_PTEIDSDK void Init (const SDK_Context *context, void *impl)
 
NOEXPORT_PTEIDSDK void Release ()
 

Static Public Member Functions

static PTEIDSDK_API void setCredentials (const char *basicAuthUser, const char *basicAuthPassword, const char *applicationId)
 

Additional Inherited Members

- Protected Member Functions inherited from eIDMW::PTEID_Object
 PTEID_Object (const SDK_Context *context, void *impl)
 
void addObject (PTEID_Object *impl)
 
void backupObject (unsigned long idx)
 
PTEID_ObjectgetObject (unsigned long idx)
 
PTEID_ObjectgetObject (void *impl)
 
void delObject (unsigned long idx)
 
void delObject (void *impl)
 
void checkContextStillOk () const
 
 PTEID_Object (const PTEID_Object &obj)
 
PTEID_Objectoperator= (const PTEID_Object &obj)
 
- Protected Attributes inherited from eIDMW::PTEID_Object
bool m_delimpl
 
void * m_impl
 
unsigned long m_ulIndexExtAdd
 
std::map< unsigned long, PTEID_Object * > m_objects
 
SDK_Context * m_context
 

Detailed Description

This class is a client for signing with Chave Móvel Digital.

Since
3.8.0

Constructor & Destructor Documentation

◆ PTEID_CMDSignatureClient()

PTEIDSDK_API eIDMW::PTEID_CMDSignatureClient::PTEID_CMDSignatureClient ( )

Default constructor

◆ ~PTEID_CMDSignatureClient()

virtual PTEIDSDK_API eIDMW::PTEID_CMDSignatureClient::~PTEID_CMDSignatureClient ( )
virtual

Destructor

Member Function Documentation

◆ getAuthentication()

virtual PTEIDSDK_API PTEID_Certificate& eIDMW::PTEID_CMDSignatureClient::getAuthentication ( )
overridevirtual
Deprecated:
Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain manually.

Implements eIDMW::PTEID_SigningDevice.

◆ getCA()

virtual PTEIDSDK_API PTEID_Certificate& eIDMW::PTEID_CMDSignatureClient::getCA ( )
overridevirtual
Deprecated:
Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain manually.

Implements eIDMW::PTEID_SigningDevice.

◆ getCert()

virtual PTEIDSDK_API PTEID_Certificate& eIDMW::PTEID_CMDSignatureClient::getCert ( PTEID_CertifType  type)
overridevirtual
Deprecated:
Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain manually.

Implements eIDMW::PTEID_SigningDevice.

◆ getCertificates()

virtual PTEIDSDK_API PTEID_Certificates& eIDMW::PTEID_CMDSignatureClient::getCertificates ( )
overridevirtual

This method returns the certificates for the account used in the last signature performed by this client. If no signature was made, it will open a dialog to introduce the CMD credentials for the account of the certificates to be obtained.

Returns
an object to access the certificate chain of a CMD account.
Warning
The PTEID_CMDSignatureClient instance manages the allocation and deletion of the PTEID_Certificates returned by getCertificates(). This means that the PTEID_Certificates can only be used while the PTEID_CMDSignatureClient exists (in Java/C# be sure to keep a reference to PTEID_CMDSignatureClient!).

Implements eIDMW::PTEID_SigningDevice.

◆ getDeviceType()

virtual PTEIDSDK_API PTEID_SigningDeviceType eIDMW::PTEID_CMDSignatureClient::getDeviceType ( )
inlineoverridevirtual

Get type of SigningDeviceType.

Implements eIDMW::PTEID_SigningDevice.

1108 { return PTEID_SigningDeviceType::CMD; }

◆ getRoot()

virtual PTEIDSDK_API PTEID_Certificate& eIDMW::PTEID_CMDSignatureClient::getRoot ( )
overridevirtual
Deprecated:
Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain manually.

Implements eIDMW::PTEID_SigningDevice.

◆ getSignature()

virtual PTEIDSDK_API PTEID_Certificate& eIDMW::PTEID_CMDSignatureClient::getSignature ( )
overridevirtual
Deprecated:
Use getCertificates() to obtain the certificates and obtain the desired certificate/build the chain manually.

Implements eIDMW::PTEID_SigningDevice.

◆ setCredentials()

static PTEIDSDK_API void eIDMW::PTEID_CMDSignatureClient::setCredentials ( const char *  basicAuthUser,
const char *  basicAuthPassword,
const char *  applicationId 
)
static

Set the credentials for the CMD services. The credentials must be set once before using the CMD services and will be used for every instance of PTEID_CMDSignatureClient.

◆ setMobileNumberCaching()

PTEIDSDK_API void eIDMW::PTEID_CMDSignatureClient::setMobileNumberCaching ( bool  enabled)

If setMobileNumberCaching is enabled, the mobile number used in a previous signature with this instance is cached and displayed in the signature dialog as a placeholder.

◆ Sign()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_CMDSignatureClient::Sign ( const PTEID_ByteArray data,
bool  signatureKey = false 
)
overridevirtual

Raw RSA signature with PCKS #1 padding.

Parameters
dataholds the data to be signed, at most 32 bytes. This data should be hashed using sha256.
signatureKeywhether 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.
Attention
The PTEID_CMDSignatureClient class only supports signature key. For that reason, signatureKey must be set to true!

Implements eIDMW::PTEID_SigningDevice.

◆ SignPDF() [1/2]

virtual PTEIDSDK_API int eIDMW::PTEID_CMDSignatureClient::SignPDF ( PTEID_PDFSignature sig_handler,
int  page,
int  page_sector,
bool  is_landscape,
const char *  location,
const char *  reason,
const char *  outfile_path 
)
overridevirtual

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.

Parameters
sig_handlerthis defines the input file and some signature options
pagein case of visible signature it defines the page where the signature will appear
page_sectorposition in the signature grid, between 1 to 18 for Portrait documents and 1 to 20 for Landscape ones
is_landscapeis unused parameter, the SDK now detects document orientation automatically
locationSignature metadata field
reasonSignature metadata field
outfile_pathNative Filesystem path of the ouput file
Deprecated:
use the SignPDF function with location coordinates instead

Implements eIDMW::PTEID_SigningDevice.

◆ SignPDF() [2/2]

virtual PTEIDSDK_API int eIDMW::PTEID_CMDSignatureClient::SignPDF ( PTEID_PDFSignature sig_handler,
int  page,
double  coord_x,
double  coord_y,
const char *  location,
const char *  reason,
const char *  outfile_path 
)
overridevirtual

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.

Parameters
sig_handlerthis defines the input file and some signature options
pagein case of visible signature it defines the page where the signature will appear
coord_xX coordinate of the signature location (percentage of page width)
coord_yY coordinate of the signature location (percentage of page height)
locationLocation field in the added signature metadata
reasonSignature metadata field
outfile_pathNative Filesystem path of the ouput file

Implements eIDMW::PTEID_SigningDevice.

◆ SignSHA256()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_CMDSignatureClient::SignSHA256 ( const PTEID_ByteArray data,
bool  signatureKey = false 
)
overridevirtual

Raw RSA signature with PCKS #1 padding (applied to a SHA256 hash).

Parameters
dataholds the data to be signed, it should be 32 bytes.
signatureKeywhether 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.
Deprecated:
This method is now deprecated. Use PTEID_SigningDevice::Sign method instead, which already supports SHA256.
Deprecated:
Use PTEID_CMDSignatureClient::Sign instead.
Attention
The PTEID_CMDSignatureClient class only supports signature key. For that reason, signatureKey must be set to true!

Implements eIDMW::PTEID_SigningDevice.

◆ SignXades()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_CMDSignatureClient::SignXades ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths,
PTEID_SignatureLevel  level = PTEID_LEVEL_BASIC 
)
overridevirtual

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.

Parameters
pathsis 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_pathsis the number of elements in the paths array
output_pathpoints to the resulting container
levelis 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.

Implements eIDMW::PTEID_SigningDevice.

◆ SignXadesA()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_CMDSignatureClient::SignXadesA ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths 
)
overridevirtual
Warning
This method is not implemented for PTEID_CMDSignatureClient.
Exceptions
PTEID_Exception(EIDMW_ERR_NOT_IMPLEMENTED)the method is not implemented.

Implements eIDMW::PTEID_SigningDevice.

◆ SignXadesAIndividual()

virtual PTEIDSDK_API void eIDMW::PTEID_CMDSignatureClient::SignXadesAIndividual ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths 
)
overridevirtual
Warning
This method is not implemented for PTEID_CMDSignatureClient.
Exceptions
PTEID_Exception(EIDMW_ERR_NOT_IMPLEMENTED)the method is not implemented.

Implements eIDMW::PTEID_SigningDevice.

◆ SignXadesIndividual()

virtual PTEIDSDK_API void eIDMW::PTEID_CMDSignatureClient::SignXadesIndividual ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths 
)
overridevirtual
Warning
This method is not implemented for PTEID_CMDSignatureClient.
Exceptions
PTEID_Exception(EIDMW_ERR_NOT_IMPLEMENTED)the method is not implemented.

Implements eIDMW::PTEID_SigningDevice.

◆ SignXadesT()

virtual PTEIDSDK_API PTEID_ByteArray eIDMW::PTEID_CMDSignatureClient::SignXadesT ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths 
)
overridevirtual
Warning
This method is not implemented for PTEID_CMDSignatureClient.
Exceptions
PTEID_Exception(EIDMW_ERR_NOT_IMPLEMENTED)the method is not implemented.

Implements eIDMW::PTEID_SigningDevice.

◆ SignXadesTIndividual()

virtual PTEIDSDK_API void eIDMW::PTEID_CMDSignatureClient::SignXadesTIndividual ( const char *  output_path,
const char *const *  paths,
unsigned int  n_paths 
)
overridevirtual
Warning
This method is not implemented for PTEID_CMDSignatureClient.
Exceptions
PTEID_Exception(EIDMW_ERR_NOT_IMPLEMENTED)the method is not implemented.

Implements eIDMW::PTEID_SigningDevice.