Skip to content

Commit e03c6d0

Browse files
authored
fix body of deprectaed sign response (#12)
1 parent 7bfcbe2 commit e03c6d0

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

service/src/main/java/digital/slovensko/autogram/service/dto/DeprecatedSignedDocumentResponse.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
package digital.slovensko.autogram.service.dto;
22

3-
import digital.slovensko.autogram.core.errors.UnrecognizedException;
43
import digital.slovensko.autogram.core.server.dto.Document;
54
import eu.europa.esig.dss.model.DSSDocument;
65

7-
import java.io.IOException;
8-
import java.util.Base64;
9-
106
public record DeprecatedSignedDocumentResponse(Document documentResponse, Signer signer) {
11-
public static DeprecatedSignedDocumentResponse buildFormDSS(DSSDocument document, String signedBy, String issuedBy) {
12-
try (var stream = document.openStream()) {
13-
return new DeprecatedSignedDocumentResponse(
14-
new Document(
15-
Base64.getEncoder().encodeToString(stream.readAllBytes()),
16-
document.getMimeType().getMimeTypeString() + ";base64",
17-
document.getName()),
18-
new Signer(signedBy, issuedBy)
19-
);
20-
} catch (IOException e) {
21-
throw new UnrecognizedException(e);
22-
}
7+
public static DeprecatedSignedDocumentResponse buildFormDSS(DSSDocument document, String signedBy, String issuedBy) {
8+
return new DeprecatedSignedDocumentResponse(
9+
(Document) Document.buildFromDSS(document),
10+
new Signer(signedBy, issuedBy)
11+
);
2312
}
2413
}
2514

0 commit comments

Comments
 (0)