Skip to content

Commit d691e68

Browse files
committed
Fix for qdigidoc and v1.0 (and possibly 1.1)
1 parent bc1f1f4 commit d691e68

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<dependency>
4343
<groupId>com.github.martinpaljak</groupId>
4444
<artifactId>esteid</artifactId>
45-
<version>17.11.26</version>
45+
<version>17.11.26.1</version>
4646
<scope>test</scope>
4747
</dependency>
4848
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->

src/main/java/org/cdoc4j/CDOCBuilder.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,16 @@ public void build() throws IOException, GeneralSecurityException {
215215
cipherdata.appendChild(payload);
216216
recipientsXML.getDocumentElement().appendChild(cipherdata);
217217

218-
// XXX: Add comments or file will not have content
218+
// XXX: qdigidoc requires at least the same number of properties as files in the payload
219+
// or the payload files willt not be shown after decryption. Having more properties
220+
// than files in the payload shrinks the file list automatically.
219221
Element props = recipientsXML.createElement("xenc:EncryptionProperties");
220-
Element prop = recipientsXML.createElement("xenc:EncryptionProperty");
221-
prop.setAttribute("Name", "orig_file");
222-
prop.setTextContent("☠ DECRYPT FIRST ☠|666|application/octet-stream|D0");
223-
props.appendChild(prop);
222+
for (String s: streams.keySet()) {
223+
Element prop = recipientsXML.createElement("xenc:EncryptionProperty");
224+
prop.setAttribute("Name", "orig_file");
225+
prop.setTextContent("☠ DECRYPT FIRST ☠|666|application/octet-stream|D0");
226+
props.appendChild(prop);
227+
}
224228
recipientsXML.getDocumentElement().appendChild(props);
225229
// Store to output stream
226230
XML.dom2stream(recipientsXML, out);

0 commit comments

Comments
 (0)