Examples of SMIMESignedGenerator


Examples of org.bouncycastle.mail.smime.SMIMESignedGenerator

     */   
    public MimeMultipart generate(MimeMessage message) throws CertStoreException,
    NoSuchAlgorithmException, NoSuchProviderException, SMIMEException {
       
        // create the generator for creating an smime/signed MimeMultipart
        SMIMESignedGenerator generator = createGenerator();
       
        // do it
        return generator.generate(message, "BC");
       
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESignedGenerator

     */   
    public MimeMultipart generate(MimeBodyPart content) throws CertStoreException,
    NoSuchAlgorithmException, NoSuchProviderException, SMIMEException {
       
        // create the generator for creating an smime/signed MimeMultipart
        SMIMESignedGenerator generator = createGenerator();
       
        // do it
        return generator.generate(content, "BC");
       
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESignedGenerator

     * @return The generated SMIMESignedGenerator.
     */   
    public SMIMESignedGenerator createGenerator() throws CertStoreException, SMIMEException {
       
        // 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
        generator.addSigner(this.privateKey, this.certificate, SMIMESignedGenerator.DIGEST_SHA1);
       
        // add our pool of certs and cerls (if any) to go with the signature
        generator.addCertificatesAndCRLs(this.certStore);
       
        return generator;
       
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESignedGenerator

     */   
    public MimeMultipart generate(MimeMessage message) throws CertStoreException,
    NoSuchAlgorithmException, NoSuchProviderException, SMIMEException {
       
        // create the generator for creating an smime/signed MimeMultipart
        SMIMESignedGenerator generator = createGenerator();
       
        // do it
        return generator.generate(message, "BC");
       
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESignedGenerator

     */   
    public MimeMultipart generate(MimeBodyPart content) throws CertStoreException,
    NoSuchAlgorithmException, NoSuchProviderException, SMIMEException {
       
        // create the generator for creating an smime/signed MimeMultipart
        SMIMESignedGenerator generator = createGenerator();
       
        // do it
        return generator.generate(content, "BC");
       
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESignedGenerator

   }

   @Test
   public void testOutput() throws Exception
   {
      SMIMESignedGenerator gen = new SMIMESignedGenerator();
      SignerInfoGenerator signer = new JcaSimpleSignerInfoGeneratorBuilder().setProvider("BC").build("SHA1WITHRSA", privateKey, cert);
      gen.addSignerInfoGenerator(signer);

      MimeMultipart mp = gen.generate(createMsg());

      output(mp);

   }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESignedGenerator

   @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);
      }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESignedGenerator

   }

   @Test
   public void testOutput2() throws Exception
   {
      SMIMESignedGenerator gen = new SMIMESignedGenerator();
      SignerInfoGenerator signer = new JcaSimpleSignerInfoGeneratorBuilder().setProvider("BC").build("SHA1WITHRSA", privateKey, cert);
      gen.addSignerInfoGenerator(signer);

      MimeMultipart mp = gen.generate(createMsg());

      ByteArrayOutputStream os = new ByteArrayOutputStream();
      mp.writeTo(os);

      ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESignedGenerator

   }

   @Test
   public void testPythonVerified() throws Exception
   {
      SMIMESignedGenerator gen = new SMIMESignedGenerator();
      SignerInfoGenerator signer = new JcaSimpleSignerInfoGeneratorBuilder().setProvider("BC").build("SHA1WITHRSA", privateKey, cert);
      gen.addSignerInfoGenerator(signer);

      MimeMultipart mp = gen.generate(createMsg());
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      mp.writeTo(os);
      String contentType = mp.getContentType();
      contentType = contentType.replace("\r\n", "").replace("\t", " ");
      System.out.println(contentType);
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESignedGenerator

   }

   @Test
   public void testPythonVerifiedBad() throws Exception
   {
      SMIMESignedGenerator gen = new SMIMESignedGenerator();
      SignerInfoGenerator signer = new JcaSimpleSignerInfoGeneratorBuilder().setProvider("BC").build("SHA1WITHRSA", badKey, cert);
      gen.addSignerInfoGenerator(signer);

      MimeMultipart mp = gen.generate(createMsg());
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      mp.writeTo(os);
      String contentType = mp.getContentType();
      contentType = contentType.replace("\r\n", "").replace("\t", " ");
      System.out.println(contentType);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.