use of com.github.zhenwei.pkix.mime.encoding.Base64OutputStream in project LinLong-Java by zhenwei1108.
the class SMIMEEnvelopedWriter method getContentStream.
public OutputStream getContentStream() throws IOException {
headers.dumpHeaders(mimeOut);
mimeOut.write(Strings.toByteArray("\r\n"));
try {
OutputStream backing = mimeOut;
if ("base64".equals(contentTransferEncoding)) {
backing = new Base64OutputStream(backing);
}
OutputStream main = envGen.open(SMimeUtils.createUnclosable(backing), outEnc);
return new ContentOutputStream(main, backing);
} catch (CMSException e) {
throw new MimeIOException(e.getMessage(), e);
}
}
use of com.github.zhenwei.pkix.mime.encoding.Base64OutputStream in project LinLong-Java by zhenwei1108.
the class SMIMESignedWriter method getContentStream.
/**
* Return a content stream for the signer - note data written to this stream needs to properly
* canonicalised if necessary.
*
* @return an output stream for data to be signed to be written to.
* @throws IOException on a stream error.
*/
public OutputStream getContentStream() throws IOException {
headers.dumpHeaders(mimeOut);
mimeOut.write(Strings.toByteArray("\r\n"));
if (boundary == null) {
// TODO: new ContentOutputStream(sigGen.open(mimeOut, true), mimeOut);
return null;
} else {
mimeOut.write(Strings.toByteArray("This is an S/MIME signed message\r\n"));
mimeOut.write(Strings.toByteArray("\r\n--"));
mimeOut.write(Strings.toByteArray(boundary));
mimeOut.write(Strings.toByteArray("\r\n"));
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
Base64OutputStream stream = new Base64OutputStream(bOut);
return new ContentOutputStream(sigGen.open(stream, false, SMimeUtils.createUnclosable(mimeOut)), mimeOut, bOut, stream);
}
}
Aggregations