mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 22:26:06 +02:00
S/MIME encryption proof of concept
This commit is contained in:
@@ -23,7 +23,6 @@ import android.content.Context;
|
||||
import android.net.MailTo;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
|
||||
import com.sun.mail.util.FolderClosedIOException;
|
||||
import com.sun.mail.util.MessageRemovedIOException;
|
||||
@@ -33,6 +32,7 @@ import org.jsoup.nodes.Document;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -58,6 +58,7 @@ import java.util.TimeZone;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.DataSource;
|
||||
import javax.activation.FileDataSource;
|
||||
import javax.activation.FileTypeMap;
|
||||
import javax.mail.Address;
|
||||
@@ -392,7 +393,27 @@ public class MessageHelper {
|
||||
ct.setParameter("smime-type", "enveloped-data");
|
||||
imessage.setDisposition(Part.ATTACHMENT);
|
||||
imessage.setFileName(attachment.name);
|
||||
imessage.setContent(Base64.encodeToString(encryptedData, Base64.DEFAULT), ct.toString());
|
||||
imessage.setDataHandler(new DataHandler(new DataSource() {
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(encryptedData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return ct.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
return imessage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user