open-eid / digidoc4j

DigiDoc for Java. Javadoc:
http://open-eid.github.io/digidoc4j
GNU Lesser General Public License v2.1
73 stars 39 forks source link

How to add multiple signers? #96

Closed wellbranding closed 2 years ago

wellbranding commented 3 years ago

Hello, how can I solve the following issue: I need multiple signers to sign a document. Each signer has a different certificate. I use that certificate to pass it to the instance of the class DataToSign with method withSigningCertificate(). However, how can I add multiple signing certificates?

Or should I use a new container for the same document and sign the same document with only a single certificate?

I am thinking about the following flow:

Get a signature from every signer, like this:

  1. Serialize the container
  2. //Finalize the signature Signature signature = dataToSign.finalize(signatureValue);

3.Then deserialize container and attach that signature.

  1. After that serialize the container again, until all recipients have signed the document, yes?

The only question remains: is it alright to serialize a container, with attached signature? I did not see it in the sample, perhaps it is not possible?

naare commented 3 years ago

Take a look at the description here: https://github.com/open-eid/digidoc4j/wiki/Examples-of-using-it#saving-container-and-datatosign-objects-during-signature-creation

This explains how to do signing in multiple steps.

You need new DataToSign object for each signer and it must be stored for finalization as described in above example.