Show / Hide Table of Contents
Edit on GitHub

Java 7+ Spring MVC samples project

The Java 7+ Spring MVC samples project shows how to use Rest PKI together with Web PKI on a Java 7+ web application using the Spring MVC framework. It is hosted on GitHub at:

https://github.com/LacunaSoftware/PkiSuiteSamples/tree/master/java/springmvc

Running the project

  1. Download the project or clone the repository
  2. Generate an API access token on the REST PKI website
  3. Paste your access token on the file Java/sample-spring-mvc/src/main/resources/application.properties
  4. In a command prompt, navigate to the folder Java/sample-spring-mvc and run the command gradlew run (on Linux ./gradlew run). If you are using Windows, you can alternatively double-click the file Run-Sample.bat.
  5. Once you see the message "Started Application in x.xxx seconds" (the on-screen percentage will not reach 100%), open a web browser and go the URL http://localhost:60963

Project map

This section lists where to find the relevant parts in each feature sample on the project.

Authentication with digital certificate

  • Controller: AuthenticationRestController
  • Views:
    • index.html (JavaScript on authentication-form.js)
    • authentication-success.html
    • authentication-failed.html

PAdES signature with file already on server

  • Controller: PadesSignatureRestController
  • Views:
    • index.html (Javascript on signature-form.js)
    • signature-info.html

PAdES signature with file uploaded by user

After the file upload (which is crudely implemented merely for demonstration purposes on the controller UploadController and view index.html) is done the control flow is the same as in the sample PAdES signature with file already on server, but with the URL parameter userfile filled.

PAdES co-signature

After the control flow of the sample PAdES signature with file already on server is completed and the link Co-sign with another certificate is clicked, the same control flow is repeated, but now with the URL parameter userfile filled.

PAdES marks

This feature is demonstrated as an optional configuration on the PAdES signature with file already on server sample which by default starts commented out. To enable it, uncomment the following line on PadesSignatureRestController:

signatureStarter.addPdfMark(PadesVisualElements.getPdfMark(1));
Tip

Try changing the argument to the getPdfMark(int) method to see different PDF mark configurations

The relevant code is on the class PadesVisualElements, method getPdfMark(int).

PAdES signature using server key

  • Controller: PadesSignatureServerKeyController
  • View: pades-signature-server-key.html

Open/validate an existing PAdES signature

  • Controller: OpenPadesRestController
  • View: index.html

Printer-friendly version

After the control flow of the sample PAdES signature with already on server is completed and the link Download a printer-friendly version of the signed file is clicked, the flow goes to the controller PrinterFriendlyPadesRestController.java with the URL parameter fileId filled.

CAdES signature with file already on server

  • Controller: CadesSignatureRestController
  • Views:
    • index.html (Javascript on signature-form.js)
    • signature-info.html

CAdES signature with file uploaded by user

After the file upload (which is crudely implemented merely for demonstration purposes on the controller UploadController and view index.html) is done the control flow is the same as in the sample CAdES signature with file already on server, but with the URL parameter userfile filled.

CAdES co-signature

After the control flow of the sample CAdES signature with file already on server is completed and the link Co-sign with another certificate is clicked, the same control flow is repeated, but now with the URL parameter cmsfile filled.

CAdES signature using server key

  • Controller: CadesSignatureServerKeyController
  • View: cades-signature-server-key.html

Open/validate an existing CAdES signature

  • Controller: OpenCadesSignatureController
  • View: open-cades-signature.html

XML signature of the entire document

  • Controller: XmlSignatureController
  • Views:
    • xml-full-signature.html (Javascript on signature-form.js)
    • xml-signature-info.html

XML signature of an element

  • Controller: XmlSignatureController
  • Views:
    • xml-element-signature.html (Javascript on signature-form.js)
    • xml-signature-info.html

XAdES signature of an element

Not yet available on this project.

Open/validate signatures on an existing XML file

  • Controller: OpenXmlSignatureController
  • View: open-xml-signature.html

Batch of PAdES signatures

  • Controller: BatchPadesSignatureRestController
  • View: index.html
    • Javascript: batch-signature-rest-form.js

Optimized batch of PAdES signatures

Not yet available on this project.

Batch of CAdES signatures

Not yet available on this project.

Batch of XML signatures of elements on the same document

Not yet available on this project.

Back to top Copyright © 2015-2020 Lacuna Software