@Override public void writeTo(SignedOutput out, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException, WebApplicationException { try { SMIMESignedGenerator gen = new SMIMESignedGenerator(); SignerInfoGenerator signer = new JcaSimpleSignerInfoGeneratorBuilder().setProvider("BC").build("SHA1WITHRSA", out.getPrivateKey(), out.getCertificate()); gen.addSignerInfoGenerator(signer); MimeMultipart mp = gen.generate(EnvelopedWriter.createBodyPart(providers, out)); String contentType = mp.getContentType(); contentType = contentType.replace("\r\n", "").replace("\t", " "); headers.putSingle("Content-Type", contentType); mp.writeTo(os); } catch (Exception e) { throw new WriterException(e); } } }
SMIMESignedGenerator gen = new SMIMESignedGenerator(); SignerInfoGenerator sigGen = new JcaSimpleSignerInfoGeneratorBuilder() .setProvider(BC) .build("SHA1withRSA", senderKey, senderCert); gen.addSignerInfoGenerator(sigGen); MimeMultipart smime = gen.generate(part); MimeBodyPart tmpBody = new MimeBodyPart(); tmpBody.setContent(smime); tmpBody.setHeader("Content-Type", smime.getContentType()); return tmpBody;
SMIMESignedGenerator sGen = new SMIMESignedGenerator( adjustDigestToOldName ? SMIMESignedGenerator.RFC3851_MICALGS : SMIMESignedGenerator.RFC5751_MICALGS); sGen.setContentTransferEncoding(getEncoding(contentTxfrEncoding));
/** * Creates an <CODE>SMIMESignedGenerator</CODE>. Includes a signer private key and certificate, * and a pool of certs and cerls (if any) to go with the signature. * @return The generated SMIMESignedGenerator. */ public SMIMESignedGenerator createGenerator() throws CertStoreException, SMIMEException, OperatorCreationException, CertificateEncodingException { // create the generator for creating an smime/signed message SMIMESignedGenerator generator = new SMIMESignedGenerator(); // add a signer to the generator - this specifies we are using SHA1 // the encryption algorithm used is taken from the key SignerInfoGenerator signerInfoGenerator = new JcaSimpleSignerInfoGeneratorBuilder() .setProvider("BC") .build("SHA1withRSA", privateKey, certificate); generator.addSignerInfoGenerator(signerInfoGenerator); // add our pool of certs and cerls (if any) to go with the signature generator.addCertificates(jcaCertStore); return generator; }
SMIMESignedGenerator signer = new SMIMESignedGenerator(); JcaSimpleSignerInfoGeneratorBuilder signerGeneratorBuilder = new JcaSimpleSignerInfoGeneratorBuilder(); signerGeneratorBuilder.setProvider(BouncyCastleProvider.PROVIDER_NAME);
SMIMESignedGenerator gen = new SMIMESignedGenerator();
final SMIMESignedGenerator aSGen = new SMIMESignedGenerator (bUseOldRFC3851MicAlgs ? SMIMESignedGenerator.RFC3851_MICALGS : SMIMESignedGenerator.RFC5751_MICALGS);
attributes.add(new SMIMEEncryptionKeyPreferenceAttribute(issAndSer)); SMIMESignedGenerator signer = new SMIMESignedGenerator();
SMIMESignedGenerator smimeSignedGenerator = new SMIMESignedGenerator("binary"); //also see CMSSignedGenerator ?
SMIMESignedGenerator smimeSignedGenerator = new SMIMESignedGenerator("binary"); //also see CMSSignedGenerator ?