{
  "openapi": "3.0.3",
  "info": {
    "title": "Namirial Sign API Service",
    "version": "2.0.0",
    "description": "**Namirial Sign: API Service**\n\nAPI Service è un servizio locale che espone un insieme di API utilizzate per la firma, l'autenticazione e il recupero delle informazioni di base sui certificati locali/di sistema, consentendo l'utilizzo di tali funzionalità da parte di applicazioni di terze parti.\n\n**Configurazione della porta**\n\nAPI Service si mette in ascolto su una porta configurabile nelle impostazioni di Namirial Sign.\nLa porta predefinita è 11543. Una volta configurata la porta, qualsiasi applicazione di terze parti dovrà essere configurata per inviare richieste a tale porta.\n"
  },
  "servers": [
    {
      "url": "https://127.0.0.1:11543",
      "description": "Endpoint locale predefinito di API Service"
    }
  ],
  "tags": [
    {
      "name": "Service",
      "description": "Endpoint per stato e ciclo di vita del servizio"
    },
    {
      "name": "Card",
      "description": "Informazioni sulla smart card e sul titolare"
    },
    {
      "name": "Certificates",
      "description": "Individuazione e reportistica dei certificati"
    },
    {
      "name": "Signing",
      "description": "Endpoint per firma di file remoti, upload e hash"
    }
  ],
  "paths": {
    "/isUp": {
      "get": {
        "tags": [
          "Service"
        ],
        "summary": "Verifica se API Service è attivo",
        "description": "Restituisce una callback JavaScript contenente la versione di API Service.",
        "operationId": "isUp",
        "parameters": [
          {
            "name": "callback",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "nullable": true,
              "default": "onIsUp"
            },
            "description": "Nome della funzione di callback."
          }
        ],
        "responses": {
          "200": {
            "description": "Callback JavaScript contenente la stringa della versione.",
            "content": {
              "text/javascript": {
                "schema": {
                  "type": "string"
                },
                "example": "onIsUp('2.0.0.0');"
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "onIsUp('2.0.0.0');"
              }
            }
          }
        }
      }
    },
    "/close": {
      "get": {
        "tags": [
          "Service"
        ],
        "summary": "Chiudi la callback di API Service",
        "description": "Restituisce la callback close().",
        "operationId": "close",
        "responses": {
          "200": {
            "description": "Callback JavaScript close().",
            "content": {
              "text/javascript": {
                "schema": {
                  "type": "string"
                },
                "example": "close();"
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "close();"
              }
            }
          }
        }
      }
    },
    "/version": {
      "get": {
        "tags": [
          "Service"
        ],
        "summary": "Ottieni la versione del servizio",
        "operationId": "getVersion",
        "responses": {
          "200": {
            "description": "Versione del servizio.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VersionResponse"
                },
                "example": {
                  "version": "2.0.0.0"
                }
              }
            }
          }
        }
      }
    },
    "/isConnected": {
      "get": {
        "tags": [
          "Service"
        ],
        "summary": "Verifica la connettività Internet",
        "operationId": "isConnected",
        "responses": {
          "200": {
            "description": "Stato del servizio.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectivityResponse"
                },
                "example": {
                  "connected": true
                }
              }
            }
          }
        }
      }
    },
    "/isValidCard": {
      "get": {
        "tags": [
          "Card"
        ],
        "summary": "Verifica la disponibilità di una smart card o di un lettore",
        "description": "Verifica la presenza di una smart card o di un lettore. Se sono presenti più lettori, viene considerato solamente il primo. Restituisce inoltre lo stato di validità del PIN e del PUK quando disponibile.",
        "operationId": "isValidCard",
        "responses": {
          "200": {
            "description": "Stato di rilevamento e validazione della smartcard.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardValidationResponse"
                },
                "examples": {
                  "detected": {
                    "value": {
                      "card": "detected",
                      "label": "DigitalDNA",
                      "certified": true,
                      "pin_status": "pin_ok",
                      "puk_status": "puk_ok"
                    }
                  },
                  "undetected": {
                    "value": {
                      "card": "undetected",
                      "label": "",
                      "certified": false,
                      "pin_status": null,
                      "puk_status": "null smart card."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/getCardholder": {
      "get": {
        "tags": [
          "Card"
        ],
        "summary": "Ottieni i dati del titolare dalla smart card",
        "description": "Recupera i dati del titolare dalla smart card. Se sono presenti più smart card, viene considerata solamente la prima.",
        "operationId": "getCardholder",
        "responses": {
          "200": {
            "description": "Stringa del soggetto associato al titolare.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardholderResponse"
                },
                "example": {
                  "cardholder": "CN=example.com,OU=Example Unit,O=Example Organization,L=Rome,S=Italy,C=IT"
                }
              }
            }
          }
        }
      }
    },
    "/findSigningCertificates": {
      "post": {
        "tags": [
          "Certificates"
        ],
        "summary": "Ricerca dei certificati di firma disponibili",
        "description": "Restituisce i certificati di firma disponibili. Utilizzare pkcs11=pkcs11 per i certificati presenti sul dispositivo e pkcs11=system per i certificati di sistema.",
        "operationId": "findSigningCertificates",
        "parameters": [
          {
            "$ref": "#/components/parameters/Pkcs11Query"
          }
        ],
        "responses": {
          "200": {
            "description": "Certificati di firma disponibili raggruppati per origine del certificato.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FindSigningCertificatesResponse"
                },
                "example": {
                  "Certificates": [
                    {
                      "Key": {
                        "CertificateLocation": "PKCS11",
                        "CardReaderName": "Bit4id Digital-DNA 0"
                      },
                      "Value": [
                        {
                          "ValidFrom": "2025-05-28 15:19:57",
                          "SerialNumber": "1000",
                          "Thumbprint": "fcc3b7d22482973174bf326285ecf825c5e927d469acf1fc85e5dfb805876e1c",
                          "Subject": "example.com",
                          "SubjectFull": "CN=example.com,OU=Example Unit,O=Example Organization,L=Rome,S=Italy,C=IT",
                          "Issuer": "example.com",
                          "IssuerFull": "CN=example.com,OU=Example Unit,O=Example Organization,L=Rome,S=Italy,C=IT",
                          "ValidUntil": "2035-05-26 15:19:57",
                          "HasPrivateKey": true,
                          "PemRepresentation": "-----BEGIN CERTIFICATE-----\\n...\\n-----END CERTIFICATE-----",
                          "KeyUsages": "DigitalSignature;Non-Repudiation",
                          "SupportedSigningHashAlgorithms": [
                            "SHA1",
                            "SHA256",
                            "SHA384",
                            "SHA512"
                          ],
                          "CertificateLocation": "PKCS11",
                          "CardReaderName": "Bit4id Digital-DNA 0",
                          "CertificateChain": [],
                          "SubjectIsUnique": true,
                          "RootCertificateThumbprint": null
                        }
                      ]
                    }
                  ],
                  "Error": null,
                  "Success": true
                }
              }
            }
          }
        }
      }
    },
    "/getCertificates": {
      "get": {
        "tags": [
          "Certificates"
        ],
        "summary": "Ottieni i certificati presenti sulla smart card",
        "operationId": "getCertificates",
        "responses": {
          "200": {
            "description": "Certificati disponibili sulla smart card.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetCertificatesResponse"
                },
                "example": {
                  "certificates": [
                    {
                      "subject": "CN=example.com,OU=Example Unit,O=Example Organization,L=Rome,S=Italy,C=IT",
                      "expiration": "26/05/35"
                    },
                    {
                      "subject": "CN=example.com,OU=Example Unit,O=Example Organization,L=Rome,S=Italy,C=IT",
                      "expiration": "26/05/35"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/restart": {
      "get": {
        "tags": [
          "Service"
        ],
        "summary": "Aggiorna le identità",
        "operationId": "restart",
        "responses": {
          "200": {
            "description": "Aggiornamento delle identità avviato o completato."
          }
        }
      }
    },
    "/log": {
      "get": {
        "tags": [
          "Certificates"
        ],
        "summary": "Ottieni il report dei certificati",
        "operationId": "getLog",
        "responses": {
          "200": {
            "description": "Report in formato testo contenente informazioni sui lettori connessi e sui certificati.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "=== Connected readers report ===\nReader: [Bit4id Digital-DNA 0]\n- ck_id: 3357b15c7b689ea593685b573beab6bec4a6e7b6f0def25fa20ab87bfbe07209 cert: example.com ca: example.com\n=== End report ==="
              }
            }
          }
        }
      }
    },
    "/signUrl": {
      "get": {
        "tags": [
          "Signing"
        ],
        "summary": "Firma un file remoto",
        "description": "Firma un file remoto in base ai parametri richiesti. Viene utilizzato il primo certificato di firma rilevato.",
        "operationId": "signUrlGet",
        "parameters": [
          {
            "$ref": "#/components/parameters/PinRequiredQuery"
          },
          {
            "$ref": "#/components/parameters/UrlRequiredQuery"
          },
          {
            "$ref": "#/components/parameters/SignatureTypeQuery"
          },
          {
            "$ref": "#/components/parameters/ResultTypeQuery"
          },
          {
            "$ref": "#/components/parameters/FilenameQuery"
          },
          {
            "$ref": "#/components/parameters/Pkcs11Query"
          },
          {
            "$ref": "#/components/parameters/UploadUrlQuery"
          },
          {
            "$ref": "#/components/parameters/SignerNameQuery"
          },
          {
            "$ref": "#/components/parameters/PageQuery"
          },
          {
            "$ref": "#/components/parameters/XQuery"
          },
          {
            "$ref": "#/components/parameters/YQuery"
          },
          {
            "$ref": "#/components/parameters/WQuery"
          },
          {
            "$ref": "#/components/parameters/HQuery"
          },
          {
            "$ref": "#/components/parameters/ImageUrlQuery"
          },
          {
            "$ref": "#/components/parameters/TsaUrlQuery"
          },
          {
            "$ref": "#/components/parameters/TsaUsernameQuery"
          },
          {
            "$ref": "#/components/parameters/TsaPasswordQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Risultato del file firmato.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignUrlResponse"
                },
                "example": {
                  "signed": "MIMByzUG..."
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Signing"
        ],
        "summary": "Firma un file remoto",
        "description": "Firma un file remoto in base ai parametri richiesti. Viene utilizzato il primo certificato di firma rilevato.",
        "operationId": "signUrlPost",
        "parameters": [
          {
            "$ref": "#/components/parameters/PinRequiredQuery"
          },
          {
            "$ref": "#/components/parameters/UrlRequiredQuery"
          },
          {
            "$ref": "#/components/parameters/SignatureTypeQuery"
          },
          {
            "$ref": "#/components/parameters/ResultTypeQuery"
          },
          {
            "$ref": "#/components/parameters/FilenameQuery"
          },
          {
            "$ref": "#/components/parameters/Pkcs11Query"
          },
          {
            "$ref": "#/components/parameters/UploadUrlQuery"
          },
          {
            "$ref": "#/components/parameters/SignerNameQuery"
          },
          {
            "$ref": "#/components/parameters/PageQuery"
          },
          {
            "$ref": "#/components/parameters/XQuery"
          },
          {
            "$ref": "#/components/parameters/YQuery"
          },
          {
            "$ref": "#/components/parameters/WQuery"
          },
          {
            "$ref": "#/components/parameters/HQuery"
          },
          {
            "$ref": "#/components/parameters/ImageUrlQuery"
          },
          {
            "$ref": "#/components/parameters/TsaUrlQuery"
          },
          {
            "$ref": "#/components/parameters/TsaUsernameQuery"
          },
          {
            "$ref": "#/components/parameters/TsaPasswordQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Risultato del file firmato.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignUrlResponse"
                },
                "example": {
                  "signed": "MIMByzUG..."
                }
              }
            }
          }
        }
      }
    },
    "/signHash": {
      "post": {
        "tags": [
          "Signing"
        ],
        "summary": "Firma un digest Base64",
        "description": "Firma un digest Base64 e apre una finestra per l'inserimento del PIN.",
        "operationId": "signHash",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SignHashRequest"
              },
              "example": {
                "HashValueBase64": "VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg==",
                "Thumbprint": "fcc3b7d22482973174bf326285ecf825c5e927d469acf1fc85e5dfb805876e1c",
                "HashAlgorithm": "sha256",
                "Pkcs11": "pkcs11",
                "Texts": {
                  "Title": "Insert PIN",
                  "Message": "PIN",
                  "Buttons": {
                    "Confirm": "OK",
                    "Cancel": "Cancel"
                  },
                  "Errors": {
                    "WrongPin": "Wrong PIN",
                    "PinLocked": "PIN Locked"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Risultato della firma dell'hash.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignHashResponse"
                },
                "example": {
                  "Result": "T99WvOXO4sokSwfp6GVq9fWLGvbY5mF4WgqOJp0zRBSZWSfBpJ1OPl8O/AALaqAA748u7grrDNa35oad6B6TbRZ8/rp+nN1gqwKCs6Om5LPye9XXaC4APnaqPK95wRXmBJ0n/c9aGNr3HIkhDSZ8TLXj5cR72fU3ka7EsJAQl+Z/i+tV1fcnBQpjtRib7RyMQApBh+VJ0qmA73Hh5eD489/4aXR6lefqK8kUsX7o2CdPC2oIQRE4m8jpB+7IR9Zlv/00SYlE/xiAh9YxxsY4UwIFhJBaI8LRFUSpAgLvHgD6l6s+nQcxagGRFGovXF55m/GXn5wJfNohJuvPR9trZQ==",
                  "Error": "",
                  "Success": true
                }
              }
            }
          }
        }
      }
    },
    "/signFile": {
      "post": {
        "tags": [
          "Signing"
        ],
        "summary": "Firma un file caricato",
        "description": "Firma un file e apre una finestra di inserimento PIN se il PIN non viene fornito.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/SignFileForm"
              }
            }
          }
        },
        "operationId": "signFile",
        "responses": {
          "200": {
            "description": "Risultato del file firmato.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignFileResponse"
                },
                "example": {
                  "result": "MIMByzUG..."
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "Pkcs11Query": {
        "name": "pkcs11",
        "in": "query",
        "required": false,
        "description": "Sorgente del certificato. Usa pkcs11 per i dispositivi fisici  e system per i certificati di sistema.",
        "schema": {
          "$ref": "#/components/schemas/Pkcs11Source"
        }
      },
      "PinRequiredQuery": {
        "name": "pin",
        "in": "query",
        "required": true,
        "description": "PIN del dispositivo.",
        "schema": {
          "type": "string"
        }
      },
      "UrlRequiredQuery": {
        "name": "url",
        "in": "query",
        "required": true,
        "description": "URL del file da firmare.",
        "schema": {
          "type": "string",
          "format": "uri"
        }
      },
      "SignatureTypeQuery": {
        "name": "type",
        "in": "query",
        "required": true,
        "description": "Tipo di firma.",
        "schema": {
          "$ref": "#/components/schemas/SignatureType"
        }
      },
      "ResultTypeQuery": {
        "name": "result",
        "in": "query",
        "required": true,
        "description": "Come ottenere l'output.",
        "schema": {
          "$ref": "#/components/schemas/SignUrlResultType"
        }
      },
      "FilenameQuery": {
        "name": "filename",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "nullable": true
        }
      },
      "UploadUrlQuery": {
        "name": "uploadUrl",
        "in": "query",
        "required": false,
        "description": "Richiesto quando result=upload, rappresenta dove eseguire l'upload.",
        "schema": {
          "type": "string",
          "format": "uri",
          "nullable": true
        }
      },
      "SignerNameQuery": {
        "name": "signerName",
        "in": "query",
        "required": false,
        "description": "Per firma grafica, nome del firmatarioe.",
        "schema": {
          "type": "string",
          "nullable": true
        }
      },
      "PageQuery": {
        "name": "page",
        "in": "query",
        "required": false,
        "description": "Per firma grafica, pagina su cui apporre la firma.",
        "schema": {
          "type": "integer",
          "nullable": true
        }
      },
      "XQuery": {
        "name": "x",
        "in": "query",
        "required": false,
        "description": "Per firma grafica, posizione orizzontale.",
        "schema": {
          "type": "number",
          "nullable": true
        }
      },
      "YQuery": {
        "name": "y",
        "in": "query",
        "required": false,
        "description": "Per firma grafica, posizione verticale.",
        "schema": {
          "type": "number",
          "nullable": true
        }
      },
      "WQuery": {
        "name": "w",
        "in": "query",
        "required": false,
        "description": "Per firma grafica, larghezza della firma.",
        "schema": {
          "type": "number",
          "nullable": true
        }
      },
      "HQuery": {
        "name": "h",
        "in": "query",
        "required": false,
        "description": "Per firma grafica, altezza della firma.",
        "schema": {
          "type": "number",
          "nullable": true
        }
      },
      "ImageUrlQuery": {
        "name": "imageUrl",
        "in": "query",
        "required": false,
        "description": "Per firma grafica, immagine da usare.",
        "schema": {
          "type": "string",
          "format": "uri",
          "nullable": true
        }
      },
      "TsaUrlQuery": {
        "name": "tsaUrl",
        "in": "query",
        "required": false,
        "description": "Per aggiungere una marca temporale, url del servizio di marca temporale.",
        "schema": {
          "type": "string",
          "format": "uri",
          "nullable": true
        }
      },
      "TsaUsernameQuery": {
        "name": "tsaUsername",
        "in": "query",
        "required": false,
        "description": "Per aggiungere una marca temporale, username.",
        "schema": {
          "type": "string",
          "nullable": true
        }
      },
      "TsaPasswordQuery": {
        "name": "tsaPassword",
        "in": "query",
        "required": false,
        "description": "Per aggiungere una marca temporale, password.",
        "schema": {
          "type": "string",
          "format": "password",
          "nullable": true
        }
      }
    },
    "schemas": {
      "Pkcs11Source": {
        "type": "string",
        "nullable": true,
        "default": "pkcs11",
        "enum": [
          "pkcs11",
          "system"
        ]
      },
      "SignatureType": {
        "type": "string",
        "enum": [
          "cades",
          "pades",
          "xades"
        ]
      },
      "SignUrlResultType": {
        "type": "string",
        "enum": [
          "link",
          "base64",
          "upload"
        ]
      },
      "SignFileResultType": {
        "type": "string",
        "enum": [
          "base64"
        ]
      },
      "VersionResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "version": {
            "type": "string",
            "example": "2.0.0.0"
          }
        },
        "required": [
          "version"
        ]
      },
      "ConnectivityResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "connected": {
            "type": "boolean"
          }
        },
        "required": [
          "connected"
        ]
      },
      "CardValidationResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "card": {
            "type": "string",
            "enum": [
              "detected",
              "undetected"
            ]
          },
          "label": {
            "type": "string"
          },
          "certified": {
            "type": "boolean"
          },
          "pin_status": {
            "type": "string",
            "nullable": true,
            "example": "pin_ok"
          },
          "puk_status": {
            "type": "string",
            "nullable": true,
            "example": "puk_ok"
          }
        },
        "required": [
          "card",
          "label",
          "certified",
          "pin_status",
          "puk_status"
        ]
      },
      "CardholderResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "cardholder": {
            "type": "string"
          }
        },
        "required": [
          "cardholder"
        ]
      },
      "FindSigningCertificatesResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "Certificates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CertificateGroup"
            }
          },
          "Error": {
            "type": "string",
            "nullable": true
          },
          "Success": {
            "type": "boolean"
          }
        },
        "required": [
          "Certificates",
          "Error",
          "Success"
        ]
      },
      "CertificateGroup": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "Key": {
            "$ref": "#/components/schemas/CertificateGroupKey"
          },
          "Value": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SigningCertificate"
            }
          }
        },
        "required": [
          "Key",
          "Value"
        ]
      },
      "CertificateGroupKey": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "CertificateLocation": {
            "$ref": "#/components/schemas/CertificateLocation"
          },
          "CardReaderName": {
            "type": "string"
          }
        },
        "required": [
          "CertificateLocation",
          "CardReaderName"
        ]
      },
      "SigningCertificate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "ValidFrom": {
            "type": "string",
            "description": "Inizio validità del certificato.",
            "example": "2025-05-28 15:19:57"
          },
          "SerialNumber": {
            "type": "string",
            "example": "1000"
          },
          "Thumbprint": {
            "type": "string",
            "example": "fcc3b7d22482973174bf326285ecf825c5e927d469acf1fc85e5dfb805876e1c"
          },
          "Subject": {
            "type": "string",
            "example": "example.com"
          },
          "SubjectFull": {
            "type": "string",
            "example": "CN=example.com,OU=Example Unit,O=Example Organization,L=Rome,S=Italy,C=IT"
          },
          "Issuer": {
            "type": "string",
            "example": "example.com"
          },
          "IssuerFull": {
            "type": "string",
            "example": "CN=example.com,OU=Example Unit,O=Example Organization,L=Rome,S=Italy,C=IT"
          },
          "ValidUntil": {
            "type": "string",
            "description": "Data di scadenza del certificato.",
            "example": "2035-05-26 15:19:57"
          },
          "HasPrivateKey": {
            "type": "boolean"
          },
          "PemRepresentation": {
            "type": "string",
            "description": "certificato in formato PEM."
          },
          "KeyUsages": {
            "type": "string",
            "description": "Key usage del certificato.",
            "example": "DigitalSignature;Non-Repudiation"
          },
          "SupportedSigningHashAlgorithms": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "SHA1",
                "SHA256",
                "SHA384",
                "SHA512"
              ]
            },
            "example": [
              "SHA1",
              "SHA256",
              "SHA384",
              "SHA512"
            ]
          },
          "CertificateLocation": {
            "$ref": "#/components/schemas/CertificateLocation"
          },
          "CardReaderName": {
            "type": "string",
            "example": "Bit4id Digital-DNA 0"
          },
          "CertificateChain": {
            "type": "array",
            "description": "Certificate chain.",
            "items": {
              "$ref": "#/components/schemas/CertificateChainItem"
            }
          },
          "SubjectIsUnique": {
            "type": "boolean"
          },
          "RootCertificateThumbprint": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "ValidFrom",
          "SerialNumber",
          "Thumbprint",
          "Subject",
          "SubjectFull",
          "Issuer",
          "IssuerFull",
          "ValidUntil",
          "HasPrivateKey",
          "PemRepresentation",
          "KeyUsages",
          "SupportedSigningHashAlgorithms",
          "CertificateLocation",
          "CardReaderName",
          "CertificateChain",
          "SubjectIsUnique",
          "RootCertificateThumbprint"
        ]
      },
      "CertificateLocation": {
        "type": "string",
        "enum": [
          "PKCS11",
          "SYSTEM"
        ]
      },
      "CertificateChainItem": {
        "type": "object",
        "description": "Certificate chain item.",
        "additionalProperties": true
      },
      "GetCertificatesResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "certificates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BasicCertificateInfo"
            }
          }
        },
        "required": [
          "certificates"
        ]
      },
      "BasicCertificateInfo": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "subject": {
            "type": "string"
          },
          "expiration": {
            "type": "string",
            "example": "26/05/35"
          }
        },
        "required": [
          "subject",
          "expiration"
        ]
      },
      "SignUrlResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "signed": {
            "type": "string"
          }
        },
        "required": [
          "signed"
        ]
      },
      "SignHashRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "HashValueBase64": {
            "type": "string",
            "description": "Base64 digest da firmare."
          },
          "Thumbprint": {
            "type": "string",
            "description": "Thumbprint del certificato da usare."
          },
          "HashAlgorithm": {
            "type": "string",
            "example": "sha256"
          },
          "Pkcs11": {
            "$ref": "#/components/schemas/Pkcs11Source"
          },
          "Texts": {
            "$ref": "#/components/schemas/PinModalTexts"
          }
        },
        "required": [
          "HashValueBase64",
          "Thumbprint",
          "HashAlgorithm"
        ]
      },
      "PinModalTexts": {
        "type": "object",
        "nullable": true,
        "additionalProperties": false,
        "properties": {
          "Title": {
            "type": "string",
            "nullable": true
          },
          "Message": {
            "type": "string",
            "nullable": true
          },
          "Buttons": {
            "$ref": "#/components/schemas/PinModalButtons"
          },
          "Errors": {
            "$ref": "#/components/schemas/PinModalErrors"
          }
        }
      },
      "PinModalButtons": {
        "type": "object",
        "nullable": true,
        "additionalProperties": false,
        "properties": {
          "Confirm": {
            "type": "string",
            "nullable": true
          },
          "Cancel": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PinModalErrors": {
        "type": "object",
        "nullable": true,
        "additionalProperties": false,
        "properties": {
          "WrongPin": {
            "type": "string",
            "nullable": true
          },
          "PinLocked": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "SignHashResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "Result": {
            "type": "string"
          },
          "Error": {
            "type": "string"
          },
          "Success": {
            "type": "boolean"
          }
        },
        "required": [
          "Result",
          "Error",
          "Success"
        ]
      },
      "SignFileForm": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "pin": {
            "type": "string",
            "nullable": true,
            "description": "Se assente, apparirà una modale per l'inserimento del PIN."
          },
          "sign_type": {
            "$ref": "#/components/schemas/SignatureType"
          },
          "res_type": {
            "$ref": "#/components/schemas/SignFileResultType"
          },
          "filename": {
            "type": "string",
            "nullable": true
          },
          "input_file": {
            "type": "string",
            "format": "binary"
          },
          "pkcs11": {
            "$ref": "#/components/schemas/Pkcs11Source"
          },
          "tsaUrl": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "tsaUsername": {
            "type": "string",
            "nullable": true
          },
          "tsaPassword": {
            "type": "string",
            "format": "password",
            "nullable": true
          }
        },
        "required": [
          "sign_type",
          "res_type",
          "input_file"
        ]
      },
      "SignFileResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "result": {
            "type": "string"
          }
        },
        "required": [
          "result"
        ]
      }
    }
  }
}