Search in sources :

Example 1 with OpenPgpDataSink

use of org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSink in project k-9 by k9mail.

the class MessageCryptoHelper method getDataSinkForDecryptedInlineData.

private OpenPgpDataSink<MimeBodyPart> getDataSinkForDecryptedInlineData() {
    return new OpenPgpDataSink<MimeBodyPart>() {

        @Override
        public MimeBodyPart processData(InputStream is) throws IOException {
            try {
                ByteArrayOutputStream decryptedByteOutputStream = new ByteArrayOutputStream();
                IOUtils.copy(is, decryptedByteOutputStream);
                TextBody body = new TextBody(new String(decryptedByteOutputStream.toByteArray()));
                return new MimeBodyPart(body, "text/plain");
            } catch (MessagingException e) {
                Timber.e(e, "MessagingException");
            }
            return null;
        }
    };
}
Also used : TextBody(com.fsck.k9.mail.internet.TextBody) MessagingException(com.fsck.k9.mail.MessagingException) InputStream(java.io.InputStream) OpenPgpDataSink(org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSink) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart)

Aggregations

MessagingException (com.fsck.k9.mail.MessagingException)1 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)1 TextBody (com.fsck.k9.mail.internet.TextBody)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 OpenPgpDataSink (org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSink)1