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.
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.
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");
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);
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);