open-eid / digidoc4j

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

Mime type exception when validating BDOC container #134

Open hello96 opened 1 month ago

hello96 commented 1 month ago

Hi everyone! I'm getting a strange error when trying to validate a BDOC container:

image

My code:

                Container container = ContainerBuilder.aContainer(DocumentType.BDOC)
                .fromExistingFile(bdocFileName)
                .build();

        // Validate the container
        ContainerValidationResult result = container.validate();

        // Check if the container is valid
        boolean isContainerValid = result.isValid();

        // Get the validation errors and warnings
        List<DigiDoc4JException> validationErrors = result.getErrors();
        List<DigiDoc4JException> validationWarnings = result.getWarnings();
        List<DigiDoc4JException> containerErrors = result.getContainerErrors();// Container format errors
        List<DigiDoc4JException> containerWarnings = result.getContainerWarnings();

        String validationReport = result.getReport();

        result.saveXmlReports(reportFileName));
        System.out.println(validationErrors);

I think that the issue might concern this function in the ContainerOpener.java class:

WhatsApp Image 2024-07-12 at 12 07 44

In fact, in the read() function at line 126 it crushes by throwing the mentioned exception, assuming that it is an ASIC container before doing the checks that would follow.

Am I doing something wrong?

Freeedy commented 1 month ago

Up

heititobi commented 1 month ago

Hello, @hello96!

Is the mime type of the container defined as application/vnd.bdoc-1.0 (found in mimetype file)? Could you please send your container to help@ria.ee so we can analyze further.

Today DigiDoc4j does support only ASIC-E standard based BDOC containers and in accordance of BDOC2.1 standard only mime type application/vnd.etsi.asic-e+zip is allowed. More information on the subject can be found here: