Pular para o conteúdo principal

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. Install JDK 21 or later.
  3. In a command prompt, navigate to the folder java/springmvc and run the command gradlew bootRun (on Linux ./gradlew bootRun). If you are using Windows, you can alternatively double-click the file Run-Sample.bat.
  4. 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:60695

Project map​

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

Authentication with digital certificate​

PAdES signature with file already on server​

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​

Open/validate an existing PAdES signature​

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​

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.

Open/validate an existing CAdES signature​

XML signature of the entire document​

XML signature of an element​

XAdES signature of an element​

Demonstrated by the digital diploma sample, which signs the DadosDiploma and DadosRegistro elements with the ICP-Brasil XAdES AD-RT policy and then the whole document with the AD-RA policy:

Open/validate signatures on an existing XML file​

Batch of PAdES signatures​

Batch of CAdES signatures​

View as Markdown