# eGov Validation Client CLI

The eGov Validation Client command line interface provides a stand-alone client for the eGov Validation Client SDK.

## Requirements

### Java Runtime Environment

To use the validation command line interface, you need to have a Java Runtime Environment with version 17 in the search path or declare an environment variable `JAVA_HOME` pointing to the root of a Java Runtime Environment installation with version 17.

## Usage

To use the validation client command line interface call the starter script—`validate.bat` for Windows or `validate.sh` for UNIX-line operating systems—with the desired options. Valid options are as follows:

    Usage: validate [-cde] [-list] [-b <dir>] [-E <certificate[:password]>] [-f
                    <filename>] [-i <filename>] [-l <lang>] [-m <mandator>] [-o
                    <filename>] [-p <proxyhost:proxyport:proxyuser:proxypass>] [-pw
                    <password>] [-rs <style>] [-s <signaturename>] [-sun
                    <serviceUserName>] [-suo <serviceUserOrganization>] [-u <url>]
                    [-un <username>]
      -b, --batch-input-dir <dir>
                                 Path to the directory containing the files to be
                                   validated. The option -b is mutually exclusive
                                   with -f.
      -c, --container-check      Container check, validates all signatures in the
                                   pdf file. The option -c is mutually exclusive
                                   with -s when using -f. This option is not
                                   supported with -b.
      -d, --dump                 Logs the JSON object of the request and response.
      -e, --unsigned             Generate report even for unsigned files
      -E, --cert <certificate[:password]>
                                 File name and optional password to use for client
                                   certificate authentication. Supported file types
                                   are PKCS12 and JKS.
      -f, --pdffile <filename>   File to validate. The option -f is mutually
                                   exclusive with -b.
      -i, --config <filename>    Name of configfile to use.
      -l, --lang <lang>          get pdf report in the given language, supported
                                   codes: de, fr, it, en. This is an optional
                                   parameter, if omitted de is used.
      -list                  List digital signatures of given PDF file (is not
                                   supported with --batch-input-dir).
      -m, --mandator <mandator>  mandator to use, e.g. Qualified, FullQualified,
                                   Strafregisterauszug, or BAKOM (Can also be
                                   defined in config file)
      -o, --report <filename>    When -f is used, a PDF report will be saved at the
                                   given name.
                                 When -b is used, a batch report and a report for
                                   each file will be generated and packaged into a
                                   ZIP file.
                                 The ZIP will be saved at the given name. The batch
                                   report will be named "batch_report.pdf"
                                 The report for each file will be named after the
                                   validated document + "_report.pdf"
                                 Example:
                                 -o C:\tmp\example_report.zip
                                 -> C:\tmp\example_report.zip (contains
                                   batch_report.pdf and per-file reports)
      -p, --proxy <proxyhost:proxyport:proxyuser:proxypass>
                                 HTTP Proxy host and port to use for accessing the
                                   validation webservice. If not present, the Java
                                   System Properties are checked. For
                                   authentication use the format proxy:port:user:
                                   password
      -pw, --password <password>
                                 password for the basic authentication
      -rs, --outputstyle <style>
                                 Defines the style of the generated pdf report,
                                   either a container with a report per signature
                                   or one report for all.The valid options are: -rs
                                   single or -rs container. The option can be
                                   omitted, default is single mode. This option is
                                   not supported with --batch-input-dir.
      -s, --signature <signaturename>
                                 Name of a signature to check in this pdf file (e.
                                   g. Signature1). Mutually exclusive with -c when
                                   using -f. This option is not supported with
                                   --batch-input-dir.
      -sun, --serviceusername <serviceUserName>
                                 name of the user requesting the validation
      -suo, --serviceuserorganization <serviceUserOrganization>
                                 organization of the user requesting the validation
      -u, --url <url>            URL of the validation webservice. (Can also be
                                   defined in config file)
      -un, --username <username>
                                 username for the basic authentication

### Configuration File

The options `-m,--mandator` , `-u,--url` and `-p,--proxy` can also be given in a configuration file in Java property file format using the option `-i,--config` to specify the name of the config file. The property names for the options are `mandator` , `validator_url` and `proxy_host` and `proxy_port` respectively.

    mandator=<value>
    validator_url=<value>
    proxy_host=<value>
    proxy_port=<value>

### Logging

The validation client command line interface uses Logback as backend for SLF4J. To customize logging output, configure Logback in file `logback.xml` in the `classes` directory. See http://logback.qos.ch/manual/configuration.html#syntax for details.

## Examples

### Validating all signatures in a file

This example assumes that

- the name of the file containing the signatures is `file.pdf`,
- that you want to apply the validation rules for `myvalidation`,
- and that the validation service is running at `https://validationserver.mydomain.com/`.

    validate -u https://validationserver.mydomain.com/ -m myvalidation -f file.pdf -c

### Validating a single signature in a file

This example assumes that

- the name of the file containing the signatures is `file.pdf`,
- that you want to apply the validation rules for `myvalidation`.
- that the name of the signature field to validate is `signature1`,
- and that the validation service is running at `https://validationserver.mydomain.com/`.

    validate -u https://validationserver.mydomain.com/ -m myvalidation -f file.pdf -s signature1

### Creating a validation report

This example assumes that

- the name of the file containing the signatures is `file.pdf`,
- that you want to apply the validation rules for `myvalidation`.
- and that the validation service is running at `https://validationserver.mydomain.com/`.

    validate -u https://validationserver.mydomain.com/ -m myvalidation -f file.pdf -c -o report.pdf

### Creating a validation report for multiple files (batch)

This example assumes that

- the name of the directory containing the pdf files to be validated is `C:\Users\user\validator\input`,
- that you want to apply the validation rules for `myvalidation`.
- and that the validation service is running at `https://validationserver.mydomain.com/`.

    validate -u https://validationserver.mydomain.com/ -m myvalidation -b C:\Users\user\validator\input -o batch_report.zip