SMimeMessageFactory { public MimeMessage createSignedMimeMessage(final String msg, MimeType mimeType, SMimeDigestMethod digestMethod) throws OxalisTransmissionException { return createSignedMimeMessage(new ByteArrayInputStream(msg.getBytes()), mimeType, digestMethod); } @Inject  SMimeMessageFactory(PrivateKey privateKey, X509Certificate ourCertificate); MimeMessage createSignedMimeMessage(final String msg, MimeType mimeType, SMimeDigestMethod digestMethod); MimeMessage createSignedMimeMessage(final InputStream inputStream, MimeType mimeType,
                                               SMimeDigestMethod digestMethod); MimeMessage createSignedMimeMessage(MimeBodyPart mimeBodyPart, SMimeDigestMethod digestMethod); MimeMessage createSignedMimeMessageNew(MimeBodyPart mimeBodyPart, Digest digest, SMimeDigestMethod digestMethod);  }
@Test public void inspectSignedMessage() throws Exception { MimeMessage signedMimeMessage = SMimeMessageFactory .createSignedMimeMessage(resourceAsStream, new MimeType("application", "xml"), SMimeDigestMethod.sha1); assertNotNull(signedMimeMessage); assertTrue(signedMimeMessage.getContent() instanceof MimeMultipart, "Not a MultiPart"); MimeMultipart mimeMultipart = (MimeMultipart) signedMimeMessage.getContent(); BodyPart bodyPart = mimeMultipart.getBodyPart(0); Object content = bodyPart.getContent(); assertTrue(content instanceof InputStream); StringWriter sw = new StringWriter(); int c; InputStream inputStream = bodyPart.getInputStream(); while ((c = inputStream.read()) >= 0) { sw.write(c); } assertTrue(sw.toString().contains("<?xml version")); }