AutoFirma Electronic Signature Suite

repository·master·Indexed 43 days ago

https://github.com/ctt-gob-es/clienteafirma

An electronic signature and identification suite for Public Administrations providing advanced authentication and signing across desktop, web, and mobile environments. It supports cryptographic logic for CAdES, PAdES, XAdES, CMS, and XMLdSig, and includes tools for keystore management and file hash generation/verification.

Tokens
6.1K
Snippets
18
Records
27
Agent score
53%

What's inside AutoFirma

  1. Install NSIS plugins and language files for Autofirma

    master

    Use the instalar-nsis-completo.bat batch script to automate the installation of required NSIS plugins (nsProcess and registry) and custom language files (.nlf and .nsh) needed to compile Autofirma installers.

    Prerequisites

    • OS: Windows 7 or higher.
    • NSIS Installation Path: Must be located at C:\Program Files (x86)\NSIS.
    • Folder Structure: The project must follow this structure:
    NSIS/
    ├── instalar-nsis-completo.bat
    ├── plugins/
    │   ├── nsProcess.dll
    │   ├── registry.dll
    │   ├── nsProcess.nsh
    │   └── Registry.nsh
    ├── Contrib/
    │   └── Language Files/
    │       ├── *.nlf
    │       └── *.nsh
    # Run the installer script
    instalar-nsis-completo.bat
  2. Use the Common directory for application development

    master

    The Common directory provides essential classes and XAML styles designed to simplify application development within the project. These components are integrated into most Visual Studio project and item templates used in this repository.

    Customizing Styles

    If you need to modify a style found in StandardStyles, do not edit the original directly. Instead, create a copy in your own resource dictionary.

    Tip: In the Visual Studio design surface, you can right-click a styled control and select Edit a Copy to quickly create a customized version.

    Modifying Common Classes

    Classes in the Common directory are part of your project and can be enhanced. However, use caution when altering existing methods or properties. Because Visual Studio templates rely on the original signatures and type names, changing them may break other parts of your application (such as newly added pages) that expect the original implementation.

  3. Use Common classes and XAML styles for application development

    master

    The Common directory provides essential classes and XAML styles designed to simplify application development within the project. These components are integrated into most Visual Studio project and item templates.

    Important Guidelines:

    • Extending Styles: If you need to modify a style found in StandardStyles, do not edit the original directly. Instead, create a copy in your own resource dictionary. You can use the Visual Studio design surface: right-click a styled control and select Edit a Copy to automate this.
    • Modifying Classes: While classes in the Common directory are part of your project and can be enhanced, be extremely cautious when altering existing methods or properties. Many Visual Studio templates and additional project pages depend on the original method signatures, property names, and type names. Incompatible changes to these core classes will break template-generated code.
  4. Build Autofirma basic modules

    master

    To compile and package the basic modules of the Autofirma project, use Apache Maven. Note that while basic client modules are compatible with Java 1.7, the JUnit libraries require Java 1.8 or higher. The Autofirma application itself is compiled directly for Java 1.8. You can append -DskipTests to any command to skip JUnit tests.

    mvn clean install
  5. Configure NSS libraries for macOS AutoFirma installer

    master

    When generating the AutoFirma installer for macOS, you must include the NSS libraries located in the nss directory to allow access to the Firefox certificate store.

    Because these libraries use the @executable_path variable to reference each other, they must be placed directly within the executable directory of the JRE (Java Runtime Environment) that is packaged alongside the application. This ensures the libraries are correctly located at runtime.

  6. Build Autofirma applications and deployable artifacts

    master

    To build the main Autofirma executable (JAR) and its associated services, use the env-install profile. This generates the following artifacts:

    • afirma-server-triphase-signer: WAR service for triphase signature generation.
    • afirma-signature-retriever: WAR service for retrieving data from the intermediate server.
    • afirma-signature-storage: WAR service for saving data to the intermediate server.
    • afirma-simple: The self-executable Autofirma JAR (Autofirma.jar).
    • afirma-ui-simple-configurator: The self-executable configurator JAR (AutofirmaConfigurador.jar) used during installation.

    You can also skip tests by adding -DskipTests to the command.

    mvn clean install -Denv=install
  7. Deploy Autofirma modules to an artifact repository

    master

    When deploying modules to an artifact repository, you must provide the application source code, JavaDoc, and sign the artifacts. To avoid generating unnecessary resources and signing during standard builds, use the env-deploy profile specifically for deployment operations.

    mvn clean deploy -Denv=deploy
  8. Download and configure NSIS plugins

    master

    If the plugins/ folder is empty, you must manually download the following plugins and place them in the project's plugins/ directory:

    1. nsProcess (Download)

      • Extract nsProcess.dll from the ZIP's Plugin/ folder to plugins/.
      • Extract nsProcess.nsh from the ZIP's Include/ folder to plugins/.
    2. registry (Download)

      • Extract registry.dll from the ZIP's Desktop/Plugin/ folder to plugins/.
      • Extract Registry.nsh from the ZIP's Desktop/Include/ folder to plugins/.

    Customizing Plugin Source Path

    If your plugins are located in a different directory, edit instalar-nsis-completo.bat and update the PLUGINS_SRC variable with the absolute path.

    set PLUGINS_SRC=C:\Users\usuario\Descargas\nsis-plugins
  9. Protocol URI Scheme: afirma://

    master

    The Cliente @firma Windows App package registers the afirma protocol. This allows other applications or web browsers to trigger the application using a URI scheme.

    Usage: You can invoke the application by calling a URL starting with afirma://. This is typically used for deep-linking or initiating specific signing workflows from a web environment.

    afirma://<parameters>
  10. Create file or directory hashes via CreateHashCommand

    master

    The CreateHashCommand allows users to generate digital fingerprints (hashes) for a single file or an entire directory. It supports both a Graphical User Interface (GUI) mode and a Command Line Interface (CLI) mode.

    Modes of Operation

    • GUI Mode: Triggered when specific GUI parameters are detected. It opens dialogs to select the main file/directory, output file, hash algorithm, hash format, and recursion settings.
    • CLI Mode: Operates via command line arguments. If an output file is specified, the result is saved to that file; otherwise, the hash (or report) is printed to the standard output.

    Behavior by Input Type

    • Directories: The command calculates hashes for all files within the directory. If recursion is enabled, it traverses subdirectories. The results are compiled into a HashDocument report using the specified directory output format.
    • Files: The command calculates the hash for the specific file. The output format determines how the hash is represented (e.g., Base64, Binary, or Hexadecimal).