Simplification

This commit is contained in:
M66B 2023-05-28 16:06:55 +02:00
parent c606108990
commit 770984647f
1 changed files with 6 additions and 8 deletions

View File

@ -4209,6 +4209,11 @@ public class FragmentCompose extends FragmentBase {
db.identity().setIdentitySignKeyAlias(identity.id, alias);
// Build content
File sinput = new File(tmp, draft.id + ".smime_sign");
try (FileOutputStream fos = new FileOutputStream(sinput)) {
bpContent.writeTo(fos);
}
if (EntityMessage.SMIME_SIGNONLY.equals(type)) {
EntityAttachment cattachment = new EntityAttachment();
cattachment.message = draft.id;
@ -4220,9 +4225,7 @@ public class FragmentCompose extends FragmentBase {
cattachment.id = db.attachment().insertAttachment(cattachment);
File content = cattachment.getFile(context);
try (OutputStream os = new FileOutputStream(content)) {
bpContent.writeTo(os);
}
Helper.copy(sinput, content);
db.attachment().setDownloaded(cattachment.id, content.length());
}
@ -4256,11 +4259,6 @@ public class FragmentCompose extends FragmentBase {
.build(contentSigner, chain[0]);
cmsGenerator.addSignerInfoGenerator(signerInfoGenerator);
File sinput = new File(tmp, draft.id + ".smime_sign");
try (FileOutputStream fos = new FileOutputStream(sinput)) {
bpContent.writeTo(fos);
}
CMSTypedData cmsData = new CMSProcessableFile(sinput);
CMSSignedData cmsSignedData = cmsGenerator.generate(cmsData);
byte[] signedMessage = cmsSignedData.getEncoded();