mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-02 15:17:03 +02:00
Sign and encrypt
This commit is contained in:
@@ -27,9 +27,11 @@ import android.webkit.MimeTypeMap;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -197,6 +199,27 @@ public class MessageHelper {
|
||||
|
||||
imessage.setSentDate(new Date());
|
||||
|
||||
if (message.from != null && message.from.length > 0)
|
||||
for (EntityAttachment attachment : attachments)
|
||||
if (attachment.available && "signature.asc".equals(attachment.name)) {
|
||||
InternetAddress from = (InternetAddress) message.from[0];
|
||||
File file = EntityAttachment.getFile(context, attachment.id);
|
||||
BufferedReader br = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
if (!line.startsWith("-----") && !line.endsWith("-----"))
|
||||
sb.append(line);
|
||||
} finally {
|
||||
if (br != null)
|
||||
br.close();
|
||||
}
|
||||
|
||||
imessage.addHeader("Autocrypt", "addr=" + from.getAddress() + "; keydata=" + sb.toString());
|
||||
}
|
||||
|
||||
for (final EntityAttachment attachment : attachments)
|
||||
if (attachment.available && "encrypted.asc".equals(attachment.name)) {
|
||||
Multipart multipart = new MimeMultipart("encrypted; protocol=\"application/pgp-encrypted\"");
|
||||
|
||||
Reference in New Issue
Block a user