Simplification

pull/212/head
M66B 1 year ago
parent c606108990
commit 770984647f

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

Loading…
Cancel
Save