BDOC format transition instructions for jDigiDoc library users

JDigiDoc library has had BDOC-TM (BDOC with timemark) format support from version 3.8 and it's not necessary to exchange libraries when migrating to BDOC format. Although the library does not have support for BDOC-TS ie ASiC- E (BDOC with timestamp) signature format.

To be able to use BDOC-TS format it's required to start using new DigiDoc4J library and use DigiDocService web service or Libdigidocpp C++ library.

NB! JDigiDoc library users should take into consideration that the library developments are planned to end in the middle of 2015 and the support will end a year after that. Because of this, when migrating to BDOC, you should consider using a new solution that has a longer support period. More information regarding DigiDoc libraries life cycle can be found here

Following use cases describe the process of adding the BDOC-TM document support to JDigiDoc library. BDOC signature structure and properties have been described in the JDigiDoc library documentation. BDOC format transition schedule can be found here.
 

1. New BDOC container creation

For new container creation the input parameters during SignedDoc object creation have to be changed according to the format, for example:

SignedDoc sdoc = new SignedDoc("BDOC", "2.1");
 
As parameters you can also use the predefined constants SignedDoc.FORMAT_BDOC and SignedDoc.BDOC_VERSION_2_1.
 

2. Reading in an existing BDOC container 

When reading a container it's possible to use SAXDigiDocFactory.readSignedDoc(String fileName) method which also identifies the container format.

Alternatively it's possible to use different SAXDigiDocFactory.readSignedDoc*() methods, but in that case you have to previously define the container format in the input parameter. To idenfity the container format it's also possible to use file extension comparison  (SAXDigiDocFactory.isBdocExtension(String fname) method) or identify format by container content (SAXDigiDocFactory.isBdocFile(InputStream is) method).

3. Adding datafiles to the BDOC container

Datafiles have to be added to the container in binary form (unlike the base64 format used for DDOC). For that the SignedDoc.addDataFile(File inputFile, String mime, String contentType) methods contentType input parameter has to be always defined as "BINARY" (defined also with a constant DataFile.CONTENT_BINARY). For example: 

sdoc.addDataFile(new File("test.txt"), "text/plain", DataFile.CONTENT_BINARY);

or

new DataFile("test.txt", DataFile.CONTENT_BINARY, "test.txt", "text/plain", sdoc);  
 

Data stored in memory can be directly added with DataFile.setBody(byte[] data) method. 

NB! Since BDOC documents dont have datafile ID identifcator value, then differently from DDOC documents the intra library DataFile.m_id variable value is set to datafile name. 

4. BDOC container signing

New signature formation process and OCSP confirmation API methods are identical for DDOC and BDOC formats and the library will internally handle all possible differences. 

To add an existing XML signature (signatures*.xml file) to the container it's possible to use SignedDoc.readSignature() method, for example: 

FileInputStream str = new FileInputStream(new File("signatures1.xml"));
sdoc.readSignature(str);
  
There are no differences in container verification and output writing for DDOC and BDOC formats when using JDigiDoc API.  

ASK FOR HELP

If you didn't find an answer to your question, send it to our team.



  • See instructions
  • Please estimate your ability to use the computer, so that we can provide you with the best guidance

         

  • Verification failed

How can we improve the article and be more helpful?
Send Close