### Accessing Smartcard Readers Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/cpp/index.html Provides examples of how to access smartcard readers and detect if a card is present. It shows how to iterate through available readers and get a context for the reader with a card. ```cpp PTEID_ReaderSet& readerSet = PTEID_ReaderSet::instance(); for( int i=0; i < readerSet.readerCount(); i++){ PTEID_ReaderContext& context = readerSet.getReaderByNum(i); if (context.isCardPresent()){ PTEID_EIDCard &card = context.getEIDCard(); // ... process card ... } } // Direct access to the reader with a card present PTEID_ReaderContext &readerContext = PTEID_ReaderSet.instance().getReader(); ``` -------------------------------- ### SDK Examples Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/index.html Contains usage examples for the Software Development Kit (SDK) of the Electronic Identification Middleware in Portugal, hosted on GitHub. ```github https://github.com/amagovpt/docs.autenticacao.gov/tree/main/SDK_Examples ``` -------------------------------- ### Windows SDK Installation (Silent) Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/manual_sdk.md Installs the Autenticação.gov SDK silently on Windows systems. The ADDLOCAL property specifies which components to install. For Windows 10 and later, it installs PteidRuntime and Crypto. For older systems, it includes VCRedist, PteidRuntime, and Crypto. ```bash msiexec /i Autenticacao.gov_Win_*.msi /qn /norestart ADDLOCAL=PteidRuntime,Crypto msiexec /i Autenticacao.gov_Win_*.msi /qn /norestart ADDLOCAL=VCRedist,PteidRuntime,Crypto ``` -------------------------------- ### Automated Installation in Windows Environments Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Provides information on the automated installation process for the Autenticação.gov application in Windows environments, often used for mass deployment. ```powershell msiexec /i Autenticacao.gov.msi /qn ``` -------------------------------- ### Automated Windows Installation Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Steps for automated installation of Autenticacao.gov software on Windows environments using MSI packages. Includes commands for adding code-signing certificates and silent installation. ```APIDOC 1. Add code-signing certificate: `certmgr -add AMA_codesigning.cer -c -s -r localMachine TrustedPublisher` 2. Install MSI package silently: `msiexec /i Autenticacao.gov-xxx.msi /qn` 3. Prevent system restart: `msiexec /i Autenticacao.gov-xxx.msi /qn /norestart` ``` -------------------------------- ### PTEID_ReaderSet.initSDK Method Documentation Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html Initializes the SDK. This method can optionally manage test cards. ```APIDOC pt.portugal.eid.PTEID_ReaderSet.initSDK: static void initSDK(bool bManageTestCard) Init the SDK (Optional). Definition PTEID_ReaderSet.cs:75 ``` -------------------------------- ### Linux .NET SDK Setup Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/manual_sdk.md Steps to set up the .NET SDK on Linux after compiling the source code. This involves running a generation script, copying generated libraries to the system's library path, and updating the library cache. ```bash dotnet eidmw/eidlibdotnetsdk/generate_cs_linux.sh cp eidmw/lib/libpteidlib_dotnet8+.so /usr/local/lib cp eidmw/lib/pteidlib_dotnet8+.dll /usr/local/lib ldconfig ``` -------------------------------- ### Instalação em Linux via Linha de Comandos Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Instruções para instalar a aplicação Autenticação.Gov em sistemas Linux utilizando a linha de comandos. Detalha os passos necessários para uma instalação bem-sucedida. ```bash # Exemplo de comando de instalação (a ser especificado) # sudo apt install autenticacao-gov ``` -------------------------------- ### Get Identity Information in XML Format Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/cpp/index.html Provides an example of how to request and retrieve specific cardholder identity information in XML format. This involves selecting the desired data fields and then obtaining the XML document. ```cpp PTEID_EIDCard &card = readerContext.getEIDCard(); unsigned long triesLeft; // Verify address PIN first if needed for certain data card.getPins().getPinByPinRef(PTEID_Pin::ADDR_PIN).verifyPin("", triesLeft, true); PTEID_XmlUserRequestedInfo requestedInfo; requestedInfo.add(XML_CIVIL_PARISH); requestedInfo.add(XML_GENDER); // ... add other requested fields ... PTEID_CCXML_Doc &ccxml = card.getXmlCCDoc(requestedInfo); const char * resultXml = ccxml.getCCXML(); ``` -------------------------------- ### Retrieving Identification Information Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/java/index.html Provides an example of how to get the eID card object and then extract identification details such as the given name and document number. ```java PTEID_EIDCard card = context.getEIDCard(); PTEID_EId eid = card.getID(); String nome = eid.getGivenName(); String nrCC = eid.getDocumentNumber(); (...) ``` -------------------------------- ### SDK Initialization and Finalization Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/manual_sdk.md Demonstrates how to initialize and release the SDK resources in C++, Java, and C#. ```C++ #include "eidlib.h" int main(int argc, char **argv){ PTEID_InitSDK(); // (...) - Código restante PTEID_ReleaseSDK(); } ``` ```Java package pteidsample; import pt.gov.cartaodecidadao.*; public class SamplePTEID { static { try { System.loadLibrary("pteidlibj"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. \n" + e); System.exit(1); } } public static void main(String[] args) { PTEID_ReaderSet.initSDK(); // (...) - Código restante PTEID_ReaderSet.releaseSDK(); } } ``` ```C# namespace PTEIDSample { class Sample{ public static void Main(string[] args){ PTEID_ReaderSet.initSDK(); // (...) - Código restante PTEID_ReaderSet.releaseSDK(); } } } ``` -------------------------------- ### Retrieve Identity Information in XML Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html This snippet shows how to get EID card information and then request specific user data in XML format. It involves getting the EID card object, verifying the PIN, adding requested data fields, and finally generating the XML document. ```cpp [PTEID_EIDCard](classpt_1_1portugal_1_1eid_1_1PTEID__EIDCard.html) eidCard = readerContext.[getEIDCard](classpt_1_1portugal_1_1eid_1_1PTEID__ReaderContext.html#a10b3821bb878703cf02246d2363ca04e)(); unsigned long triesLeft; ... eidCard.[getPins](classpt_1_1portugal_1_1eid_1_1PTEID__SmartCard.html#ab4d99c71398fc5f555dbe6a41284ad64)().[getPinByPinRef](classpt_1_1portugal_1_1eid_1_1PTEID__Pins.html#a0c81b93cd9881eea5f36d6fe6094e4f0)([PTEID_Pin](classpt_1_1portugal_1_1eid_1_1PTEID__Pin.html).[ADDR_PIN](classpt_1_1portugal_1_1eid_1_1PTEID__Pin.html#ab9075e4246220082c290237668f89835)).[verifyPin](classpt_1_1portugal_1_1eid_1_1PTEID__Pin.html#a305335eb4a96ef8d05f8d3c56ac791e1)("", triesLeft, true); [PTEID_XmlUserRequestedInfo](classpt_1_1portugal_1_1eid_1_1PTEID__XmlUserRequestedInfo.html) requestedInfo; requestedInfo.[add](classpt_1_1portugal_1_1eid_1_1PTEID__XmlUserRequestedInfo.html#a05eca20df2f8577ff415c9deeaac1493)(XML_CIVIL_PARISH); ... requestedInfo.[add](classpt_1_1portugal_1_1eid_1_1PTEID__XmlUserRequestedInfo.html#a05eca20df2f8577ff415c9deeaac1493)(XML_GENDER); [PTEID_CCXML_Doc](classpt_1_1portugal_1_1eid_1_1PTEID__CCXML__Doc.html) ccxml = eidCard.[getXmlCCDoc](classpt_1_1portugal_1_1eid_1_1PTEID__EIDCard.html#a49984fca51a64cceb4932fdf4b88bb54)(requestedInfo); string resultXml = ccxml.[getCCXML](classpt_1_1portugal_1_1eid_1_1PTEID__CCXML__Doc.html#a963fcf49078b57a3602c9a2b06bf08cd)(); ``` -------------------------------- ### Configuração de Ambiente CMD para Pré-produção Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/manual_sdk.md Demonstra como configurar o SDK para utilizar um ambiente CMD de pré-produção através da classe PTEID_Config. A configuração é guardada localmente e afeta futuras execuções. ```java PTEID_Config config = new PTEID_Config(PTEID_Param.PTEID_PARAM_CMD_HOST); config.setString("preprod.cmd.autenticacao.gov.pt"); ``` -------------------------------- ### Get Card Holder Picture Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/cpp/index.html Demonstrates how to retrieve the cardholder's photo from the eID card in both JPEG2000 (RAW) and PNG formats. ```cpp PTEID_EIDCard &card = readerContext.getEIDCard(); PTEID_EId& eid = card.getID(); PTEID_Photo& photoObj = eid.getPhotoObj(); PTEID_ByteArray& praw = photoObj.getphotoRAW(); // jpeg2000 format PTEID_ByteArray& ppng = photoObj.getphoto(); // PNG format ``` -------------------------------- ### Configurar Credenciais e Obter Dispositivo de Assinatura Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/manual_sdk.md Exemplos de como configurar credenciais para PTEID_CMDSignatureClient e obter um dispositivo de assinatura usando PTEID_SigningDeviceFactory. O código demonstra a ativação de múltiplas opções de assinatura, resultando na apresentação de uma janela para o utilizador escolher. ```c++ PTEID_CMDSignatureClient::setCredentials(BASIC_AUTH_USER, BASIC_AUTH_PASSWORD, BASIC_AUTH_APPID); PTEID_SigningDeviceFactory &factory = PTEID_SigningDeviceFactory::instance(); PTEID_SigningDevice &signingDev = factory.getSigningDevice(true, true); ``` ```java PTEID_CMDSignatureClient.setCredentials(BASIC_AUTH_USER, BASIC_AUTH_PASSWORD, BASIC_AUTH_APPID); PTEID_SigningDeviceFactory factory = PTEID_SigningDeviceFactory.instance(); PTEID_SigningDevice signingDev = factory.getSigningDevice(true, true); ``` ```csharp PTEID_CMDSignatureClient.setCredentials(BASIC_AUTH_USER, BASIC_AUTH_PASSWORD, BASIC_AUTH_APPID); PTEID_SigningDeviceFactory factory = PTEID_SigningDeviceFactory.instance(); PTEID_SigningDevice signingDev = factory.getSigningDevice(true, true); ``` -------------------------------- ### Get Address Information Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/cpp/index.html Shows how to obtain address details from the eID card after successfully verifying the address PIN. It includes retrieving the municipality. ```cpp PTEID_EIDCard &card = readerContext.getEIDCard(); unsigned long triesLeft; PTEID_Pins &pins = card.getPins(); PTEID_Pin &pin = pins.getPinByPinRef(PTEID_Pin.ADDR_PIN); if (pin.verifyPin("", &triesLeft, true)){ PTEID_Address &addr = card.getAddr(); const char * municipio = addr.getMunicipality(); // ... other address fields ... } ``` -------------------------------- ### Configuração de Assembly Binding Redirect para .Net Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/manual_sdk.md Exemplo de como configurar um assembly binding redirect no ficheiro de configuração da aplicação .Net para atualizar o middleware sem recompilação. Este método é aplicável a DLLs 'strong-named'. ```.Net ``` -------------------------------- ### Get Card Holder Information (Name, Document Number) Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/cpp/index.html Illustrates how to retrieve basic cardholder information such as the given name and document number from an eID card. ```cpp PTEID_EIDCard &card = readerContext.getEIDCard(); PTEID_EId& eid = card.getID(); std::string nome = eid.getGivenName(); std::string nrCC = eid.getDocumentNumber(); ``` -------------------------------- ### Instalação em Microsoft Windows Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Passos detalhados para instalar a aplicação Autenticação.gov em sistemas Microsoft Windows, incluindo opções de instalação simples e avançada. ```pt 1. Executar o pacote de instalação: Após ter descarregado o ficheiro de instalação, deverá fazer duplo clique sobre este. 2. No primeiro ecrã interativo, deverá marcar a caixa para aceitar os termos e condições da aplicação. Para uma instalação simples, pressione **Instalar** (prossiga para o passo 5). Para uma instalação avançada, pressione **Avançadas**. A instalação avançada permite configurar o caminho para a pasta de instalação e as funcionalidades a serem instaladas. 3. Após selecionar **Avançadas**, poderá escolher a pasta onde deseja instalar a aplicação. Se desejar alterar a pasta predefinida, carregue em **Alterar** e na janela que surgir, navegue até à pasta de destino e carregue **OK**. Para continuar a instalação na pasta de destino, deverá premir o botão **Seguinte**. 4. Deverá aparecer um ecrã para escolher as funcionalidades a serem instaladas. As funcionalidades são representadas numa árvore em que cada funcionalidade possui um botão para a incluir ou excluir da instalação. Ao selecionar uma funcionalidade, será apresentada a sua descrição e o espaço necessário para a sua instalação. Para instalar as funcionalidades selecionadas, clique em **Instalar**. 5. Após a conclusão deste assistente, este solicitará a reinicialização do computador. 6. No próximo arranque do *Windows* a instalação da aplicação estará finalizada. ``` -------------------------------- ### Command Line Interface Help and Version Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Provides information on how to access help and version details for the command-line interface of the Autenticação.gov application. ```cli autenticacao.gov --help autenticacao.gov --version ``` -------------------------------- ### Get Card Contact Interface and Type Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html Retrieves the contactless interface and type of a card. It first checks if a card is present in the reader. If a card is present, it calls `getCardContactInterface()` and `getCardType()` to obtain the relevant information. ```cs if (readerContext.isCardPresent()) { contactInterface = readerContext.getCardContactInterface(); cardType = readerContext.getCardType(); } ``` -------------------------------- ### PACE Authentication for Contactless Cards Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html Initiates PACE authentication for contactless cards that support the IAS5 standard. This involves getting the card instance, checking the interface and type, and then calling `initPaceAuthentication` with the Card Access Number (CAN). ```cs //Gets the card instance eidCard = readerContext.getEIDCard(); //If the contactInterface is contactless and the card supports contactless then authenticate with PACE if (contactInterface == PTEID_CardContactInterface.PTEID_CARD_CONTACTLESS && cardType == PTEID_CardType.PTEID_CARDTYPE_IAS5){ Console.WriteLine("Insert the Card access number (CAN) for the card in use: "); string can_str = Console.ReadLine(); uint can_size = (uint)can_str.Length; // Initializes PACE authentication with the provided CAN eidCard.initPaceAuthentication(can_str, can_size, PTEID_CardPaceSecretType.PTEID_CARD_SECRET_CAN); } ``` -------------------------------- ### Java SDK Initialization and Loading Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/java/index.html Demonstrates how to load the JNI library and initialize/release the SDK. This is crucial for the Java wrapper functions to work correctly. ```java package pteidsample; import pt.gov.cartaodecidadao.*; (...) static { try { System.loadLibrary("pteidlibj"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. \n" + e); System.exit(1); } } public class SamplePTEID { public static void main(String[] args) { PTEID_ReaderSet.initSDK(); (...) PTEID_ReaderSet.releaseSDK(); } } ``` -------------------------------- ### Configuração Adicional em Ubuntu 22.04 Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Comando necessário em Ubuntu 22.04 para garantir o acesso ao Cartão de Cidadão através do serviço pcscd. ```bash sudo systemctl enable pcscd.socket ``` -------------------------------- ### Retrieve and Verify Address PIN Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html This snippet demonstrates how to get the EID card object, retrieve PINs, select the address PIN, and verify it. It includes error handling for PIN verification and retrieves the municipality if verification is successful. ```cpp PTEID_EIDCard eidCard = readerContext.getEIDCard(); unsigned long triesLeft; PTEID_Pins pins = eidCard.getPins(); PTEID_Pin pin = pins.getPinByPinRef(PTEID_Pin.ADDR_PIN); if (pin.verifyPin("", &triesLeft, true)) { PTEID_Address addr = eidCard.getAddr(); string municipio = addr.getMunicipality(); } ``` -------------------------------- ### Instalação Flatpak em Linux Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Instala a aplicação Autenticação.Gov utilizando o formato Flatpak. Requer a desinstalação de versões nativas do pteid-mw e a instalação do Flatpak e pcsc-lite. ```bash sudo apt remove pteid-mw flatpak install pteid-mw-linux.x86_64.flatpak ``` -------------------------------- ### Retrieve Card Holder Name and Document Number Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html This snippet demonstrates how to get the EID card from the reader context, then extract the ID document, and finally retrieve the card holder's given name and document number. ```C# PTEID_EIDCard eidCard = readerContext.getIDCard(); PTEID_EId eid = eidCard.getID(); string nome = eid.getGivenName(); string nrCC = eid.getDocumentNumber(); ``` -------------------------------- ### Assinatura de Bloco de Dados Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/manual_sdk.md Permite assinar um bloco de dados utilizando o método Sign() de uma classe que implemente PTEID_SigningDevice. O algoritmo suportado é RSA-SHA256, exigindo que o input seja o hash SHA-256 dos dados. Novos cartões suportam ECDSA com secp256r1, mas requerem conversão para ASN1. ```C++ PTEID_ByteArray data_to_sign; (...) PTEID_ByteArray output = signingDev.Sign(data_to_sign, true); (...) ``` ```Java PTEID_ByteArray data_to_sign; (...) PTEID_ByteArray output= signingDev.Sign(data_to_sign, true); (...) ``` ```C# PTEID_ByteArray data_to_sign, output; (...) PTEID_ByteArray output; output = signingDev.Sign(data_to_sign, true); (...) ``` -------------------------------- ### Access First Reader with Card Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html This snippet shows a more direct way to access the first smartcard reader that has a card present. It uses the PTEID library's instance method to get a reader set and then retrieves the first available reader with a card. ```C++ PTEID_ReaderContext readerContext = PTEID_ReaderSet::instance().getReader(); // Process the reader context, which might contain an EID card ``` -------------------------------- ### Retrieve Cardholder Photo Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html This snippet demonstrates how to get the cardholder's photo from an EID card. It retrieves the EID card object, then the EId object, followed by the Photo object. Finally, it accesses the raw photo data in JPEG-2000 format and the converted photo in PNG format. ```Java PTEID_EIDCard eidCard = readerContext.getEIDCard(); PTEID_EId eid = eidCard.getID(); PTEID_Photo photoObj = eid.getPhotoObj(); // Get photo in JPEG-2000 format PTEID_ByteArray praw = photoObj.getphotoRAW(); // Get photo in PNG format PTEID_ByteArray ppng = photoObj.getphoto(); ``` -------------------------------- ### Acesso a Smartcard com Cartão de Cidadão Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/manual_sdk.md Este snippet demonstra como iterar sobre os leitores de smartcard, verificar a presença de um cartão e obter o objeto PTEID_EIDCard. ```C++ PTEID_ReaderSet& readerSet = PTEID_ReaderSet::instance(); for( int i=0; i < readerSet.readerCount(); i++){ PTEID_ReaderContext& context = readerSet.getReaderByNum(i); if (context.isCardPresent()){ PTEID_EIDCard &card = context.getEIDCard(); (...) } } ``` ```Java PTEID_EIDCard card; PTEID_ReaderContext context; PTEID_ReaderSet readerSet; readerSet = PTEID_ReaderSet.instance(); for( int i=0; i < readerSet.readerCount(); i++){ context = readerSet.getReaderByNum(i); if (context.isCardPresent()){ card = context.getEIDCard(); (...) } } ``` ```C# PTEID_EIDCard card; PTEID_ReaderContext context; PTEID_ReaderSet readerSet; readerSet = PTEID_ReaderSet.instance(); for( int i=0; i < readerSet.readerCount(); i++){ context = readerSet.getReaderByNum(i); if (context.isCardPresent()){ card = context.getEIDCard(); (...) } } ``` -------------------------------- ### SDK Initialization and Release Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/cpp/index.html Demonstrates the basic initialization and release of the Portuguese eID Middleware SDK. This is a fundamental step before interacting with any eID card functionalities. ```cpp #include "eidlib.h" int main(int argc, char **argv){ PTEID_InitSDK(); // ... application logic ... PTEID_ReleaseSDK(); return 0; } ``` -------------------------------- ### Manual Root Certificate Installation Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Alternative method for manually installing the State root certificate by following instructions from the SCEE installation manual. This is for users with application versions prior to 3.4.0 or when automatic installation fails. Focuses on the 'Certificado da Entidade de Certificação Eletrónica do Estado - ECRaizEstado 002'. ```pt 1. Aceda ao manual de instalação da cadeia do SCEE em https://www.ecce.gov.pt/certificados/. 2. Siga as instruções específicas para o “Certificado da Entidade de Certificação Eletrónica do Estado - ECRaizEstado 002”. 3. Execute os passos 4.1 a 4.10 do manual para a instalação manual. ``` -------------------------------- ### Initialize and Release SDK (C#) Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html Demonstrates the basic initialization and release of the Portuguese eID Middleware SDK. This involves calling `initSDK` before using any SDK functionalities and `releaseSDK` when done to free up resources. Ensure these calls are placed appropriately within your application's lifecycle. ```C# using pt.portugal.eid; static void Main(string[] args){ PTEID_ReaderSet.initSDK(false); // Initialize the SDK // ... application logic using the SDK ... PTEID_ReaderSet.releaseSDK(); // Release the SDK } ``` -------------------------------- ### Instalação Flatpak em ChromeOS Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Instala a aplicação Autenticação.Gov em ChromeOS utilizando o formato Flatpak. Requer a instalação do Flatpak e a execução do pacote descarregado. ```bash flatpak install pteid-mw-linux.x86_64.flatpak flatpak run pt.gov.autenticacao ``` -------------------------------- ### Verify PAdES Signature Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/cpp/index.html Information on verifying PAdES signatures, with a reference to a Java iText SDK example for a concrete implementation. ```Java See https://github.com/itext/i7js-samples/tree/master/publications/signatures/src/test/java/com/itextpdf/samples/signatures/chapter05 for a concrete example of how to verify a signature. ``` -------------------------------- ### Package Navigation Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/java/allpackages-index.html Provides navigation links for exploring project packages, including overview, package details, class hierarchy, deprecated items, index, and help. ```html * [Overview](index.html) * [Package](pt/gov/cartaodecidadao/package-summary.html) * Class * [Tree](overview-tree.html) * [Deprecated](deprecated-list.html) * [Index](index-all.html) * [Help](help-doc.html) * [All Classes](allclasses.html) ``` -------------------------------- ### Verifying a PAdES Signature Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html Guidance on verifying a PAdES signature using the Java iText SDK. A concrete example can be found in the iText GitHub repository. ```Java // One can verify a PAdES signature using the Java iText SDK. // See https://github.com/itext/i7js-samples/tree/master/publications/signatures/src/test/java/com/itextpdf/samples/signatures/chapter05 for a concrete example of how to verify a signature. ``` -------------------------------- ### Verificação de Atualizações da Aplicação Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Permite verificar manualmente a existência de atualizações para a aplicação. Se houver atualizações disponíveis e o utilizador desejar, o download do instalador é feito automaticamente e o processo de instalação é iniciado. ```APIDOC Atualizações: Verificar Atualizações: Descrição: Verifica manualmente se existem atualizações para a aplicação. Ação em Caso de Atualização: - Download automático do instalador. - Iniciação automática do processo de instalação (se o utilizador desejar). ``` -------------------------------- ### Accessing eID Card via ReaderSet Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/java/index.html Shows how to get an instance of the PTEID_ReaderSet and iterate through available readers to access an eID card if present. It also demonstrates a more direct method to get a reader context. ```java PTEID_EIDCard card; PTEID_ReaderContext context; PTEID_ReaderSet readerSet; readerSet = PTEID_ReaderSet.instance(); for( int i=0; i < readerSet.readerCount(); i++){ context = readerSet.getReaderByNum(i); if (context.isCardPresent()){ card = context.getEIDCard(); (...) } } PTEID_ReaderContext readerContext = PTEID_ReaderSet.instance().getReader(); PTEID_EIDCard card = readerContext.getEIDCard(); ``` -------------------------------- ### Assinatura de PDF com C++ Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/manual_sdk.md Exemplo de como assinar um ficheiro PDF utilizando a biblioteca C++ do SDK. Demonstra a configuração de níveis de assinatura PAdES, a adição de imagens personalizadas, a especificação da localização e motivo da assinatura, e o processo de assinatura. ```C++ #include "eidlib.h" (...) //Ficheiro PDF a assinar PTEID_PDFSignature signature("/home/user/input.pdf"); /* Adicionar uma imagem customizada à assinatura visível O array de bytes image_data deve conter uma imagem em formato JPEG com as dimensões obrigatórias: (351x77 px) */ PTEID_ByteArray jpeg_data(image_data, image_length); signature.setCustomImage(jpeg_data); // No caso de se querer o formato pequeno da assinatura signature.enableSmallSignatureFormat(); /* Configurar o perfil da assinatura: PAdES-B: PTEID_SignatureLevel::PTEID_LEVEL_BASIC (configurado por defeito) PAdES-T: PTEID_SignatureLevel::PTEID_LEVEL_TIMESTAMP PAdES-LT: PTEID_SignatureLevel::PTEID_LEVEL_LT PAdES-LTA: PTEID_SignatureLevel::PTEID_LEVEL_LTV */ signature.setSignatureLevel(PTEID_SignatureLevel::PTEID_LEVEL_TIMESTAMP); //Especificar local da assinatura e motivo const char * location = "Lisboa, Portugal"; const char * reason = "Concordo com o conteudo do documento"; //Especificar o número da página e a posição nessa mesma página onde a indicação visual da assinatura aparece int page = 1; double pos_x = 0.1; //Valores de 0 a 1 double pos_y = 0.1; //Valores de 0 a 1 eidCard.SignPDF(signature, page, pos_x, pos_y, location, reason, "/home/user/output.pdf"); ``` -------------------------------- ### Verify and Change PINs Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/cpp/index.html Provides an example of how to verify and subsequently change a PIN, specifically the address PIN. It includes checking the number of remaining tries before attempting to change the PIN. ```C++ PTEID_EIDCard &card = readerContext.getEIDCard(); unsigned long triesLeft; (...) PTEID_Pins &pins = card.getPins(); PTEID_Pin &pin = pins.getPinByPinRef(PTEID_Pin.ADDR_PIN); if (pin.verifyPin("", &triesLeft, true)){ bool bResult = pin.changePin("", "", triesLeft, pin.getLabel()); if (!bResult && -1 == triesLeft) return; } ``` -------------------------------- ### Batch File Signing (XAdES) Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/sdk/csharp/index.html Demonstrates how to sign multiple files in batch mode using different XAdES signature levels (simple, timestamp, archival). The output is a zip file containing all signed files. ```C# string[] files = {"test/File1.txt", "test/File2.pdf", "test/File3.md", "test/File4.cpp"}; string destination = "test/files_signed.zip"; //the output file that will contain all signatures int n_paths = 4; // size of files array // simple signature (1 unique signature for all files) eidCard.SignXades(destination, files, n_paths); // timestamp signature (1 unique signature of type T (Timestamp) for all files) eidCard.SignXadesT(destination, files, n_paths); // archival signature (1 unique signature of type A(archival) for all files) eidCard.SignXadesA(destination, files, n_paths); ``` -------------------------------- ### Atualização da Aplicação Autenticação.Gov em Linux Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Instruções para atualizar a aplicação Autenticação.Gov em Linux. Menciona a transferência do ficheiro de instalação e a referência à secção de instalação via linha de comandos. ```Linux Transferir o ficheiro de instalação através do menu Configurações -> Atualizações da aplicação. Seguir os passos indicados na secção Instalação através da linha de comandos. ``` -------------------------------- ### Install Root Certificate via Application Source: https://github.com/amagovpt/docs.autenticacao.gov/blob/main/user_manual.md Instructions for installing the new State root certificate using the Citizen Card application. This ensures that certificates issued after April 4, 2020, are trusted by Windows and other applications. Requires application version 3.4.0 or later. ```pt 1. Abra a aplicação do Cartão de Cidadão. 2. Navegue até o submenu [Configuração de assinaturas]. 3. Clique no botão **Instalar certificado** na secção **Novo certificado raiz do Estado**. 4. O certificado será adicionado à *Store* “Trusted Root Certification Authorities” associada ao “Current User”. ```