Skip to content

Commit

Permalink
fix body of deprectaed sign response (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
celuchmarek authored Nov 18, 2024
1 parent 7bfcbe2 commit e03c6d0
Showing 1 changed file with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
package digital.slovensko.autogram.service.dto;

import digital.slovensko.autogram.core.errors.UnrecognizedException;
import digital.slovensko.autogram.core.server.dto.Document;
import eu.europa.esig.dss.model.DSSDocument;

import java.io.IOException;
import java.util.Base64;

public record DeprecatedSignedDocumentResponse(Document documentResponse, Signer signer) {
public static DeprecatedSignedDocumentResponse buildFormDSS(DSSDocument document, String signedBy, String issuedBy) {
try (var stream = document.openStream()) {
return new DeprecatedSignedDocumentResponse(
new Document(
Base64.getEncoder().encodeToString(stream.readAllBytes()),
document.getMimeType().getMimeTypeString() + ";base64",
document.getName()),
new Signer(signedBy, issuedBy)
);
} catch (IOException e) {
throw new UnrecognizedException(e);
}
public static DeprecatedSignedDocumentResponse buildFormDSS(DSSDocument document, String signedBy, String issuedBy) {
return new DeprecatedSignedDocumentResponse(
(Document) Document.buildFromDSS(document),
new Signer(signedBy, issuedBy)
);
}
}

Expand Down

0 comments on commit e03c6d0

Please sign in to comment.