Blame SOURCES/0002-bcmail-api-change.patch

07f3db
diff -up ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/EnvelopedInputImpl.java.ade1 ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/EnvelopedInputImpl.java
07f3db
--- ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/EnvelopedInputImpl.java.ade1	2014-06-26 16:24:28.166315424 +0800
07f3db
+++ ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/EnvelopedInputImpl.java	2014-06-26 17:32:29.632936971 +0800
07f3db
@@ -3,6 +3,7 @@ package org.jboss.resteasy.security.smim
07f3db
 import org.bouncycastle.cms.RecipientInformation;
07f3db
 import org.bouncycastle.cms.RecipientInformationStore;
07f3db
 import org.bouncycastle.cms.jcajce.JceKeyTransRecipientId;
07f3db
+import org.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipient;
07f3db
 import org.bouncycastle.mail.smime.SMIMEEnveloped;
07f3db
 import org.bouncycastle.mail.smime.SMIMEUtil;
07f3db
 import org.jboss.resteasy.core.Headers;
07f3db
@@ -159,7 +160,8 @@ public class EnvelopedInputImpl implemen
07f3db
          RecipientInformationStore recipients = m.getRecipientInfos();
07f3db
          RecipientInformation recipient = recipients.get(recId);
07f3db
 
07f3db
-         decrypted = SMIMEUtil.toMimeBodyPart(recipient.getContent(pKey, "BC"));
07f3db
+         decrypted = SMIMEUtil.toMimeBodyPart(recipient.getContent(
07f3db
+             new JceKeyTransEnvelopedRecipient(pKey).setProvider("BC")));
07f3db
       }
07f3db
       catch (Exception e1)
07f3db
       {
07f3db
diff -up ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/MultipartSignedInputImpl.java.ade1 ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/MultipartSignedInputImpl.java
07f3db
--- ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/MultipartSignedInputImpl.java.ade1	2014-06-26 17:07:37.679401083 +0800
07f3db
+++ ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/MultipartSignedInputImpl.java	2014-06-26 17:11:10.734149755 +0800
07f3db
@@ -2,6 +2,7 @@ package org.jboss.resteasy.security.smim
07f3db
 
07f3db
 import org.bouncycastle.cms.SignerInformation;
07f3db
 import org.bouncycastle.cms.SignerInformationStore;
07f3db
+import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder;
07f3db
 import org.bouncycastle.mail.smime.SMIMESigned;
07f3db
 import org.jboss.resteasy.util.GenericType;
07f3db
 
07f3db
@@ -157,7 +158,8 @@ public class MultipartSignedInputImpl im
07f3db
 
07f3db
       SignerInformationStore signers = signed.getSignerInfos();
07f3db
       SignerInformation signer = (SignerInformation) signers.getSigners().iterator().next();
07f3db
-      return signer.verify(publicKey, "BC");
07f3db
+      return signer.verify(new JcaSimpleSignerInfoVerifierBuilder()
07f3db
+             .setProvider("BC").build(publicKey));
07f3db
 
07f3db
    }
07f3db
 
07f3db
diff -up ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/PKCS7SignatureInput.java.ade1 ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/PKCS7SignatureInput.java
07f3db
--- ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/PKCS7SignatureInput.java.ade1	2014-06-26 16:36:24.564853001 +0800
07f3db
+++ ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/PKCS7SignatureInput.java	2014-06-26 18:52:43.301108577 +0800
07f3db
@@ -3,6 +3,7 @@ package org.jboss.resteasy.security.smim
07f3db
 import org.bouncycastle.cms.CMSException;
07f3db
 import org.bouncycastle.cms.CMSSignedData;
07f3db
 import org.bouncycastle.cms.SignerInformation;
07f3db
+import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder;
07f3db
 import org.jboss.resteasy.specimpl.MultivaluedMapImpl;
07f3db
 import org.jboss.resteasy.util.Base64;
07f3db
 import org.jboss.resteasy.util.GenericType;
07f3db
@@ -206,7 +207,8 @@ public class PKCS7SignatureInput<T>
07f3db
       for (Object info : data.getSignerInfos().getSigners())
07f3db
       {
07f3db
          SignerInformation signer = (SignerInformation)info;
07f3db
-         if (signer.verify(certificate, "BC"))
07f3db
+         if (signer.verify(new JcaSimpleSignerInfoVerifierBuilder()
07f3db
+             .setProvider("BC").build(certificate)))
07f3db
          {
07f3db
             return true;
07f3db
          }
07f3db
@@ -218,7 +220,8 @@ public class PKCS7SignatureInput<T>
07f3db
       for (Object info : data.getSignerInfos().getSigners())
07f3db
       {
07f3db
          SignerInformation signer = (SignerInformation)info;
07f3db
-         if (signer.verify(publicKey, "BC"))
07f3db
+         if (signer.verify(new JcaSimpleSignerInfoVerifierBuilder()
07f3db
+             .setProvider("BC").build(publicKey)))
07f3db
          {
07f3db
             return true;
07f3db
          }
07f3db
diff -up ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/PKCS7SignatureWriter.java.ade1 ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/PKCS7SignatureWriter.java
07f3db
--- ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/PKCS7SignatureWriter.java.ade1	2014-06-24 23:38:42.464516920 +0800
07f3db
+++ ./jaxrs/security/resteasy-crypto/src/main/java/org/jboss/resteasy/security/smime/PKCS7SignatureWriter.java	2014-06-26 18:05:06.601349666 +0800
07f3db
@@ -4,7 +4,13 @@ import org.bouncycastle.cms.CMSException
07f3db
 import org.bouncycastle.cms.CMSProcessable;
07f3db
 import org.bouncycastle.cms.CMSProcessableByteArray;
07f3db
 import org.bouncycastle.cms.CMSSignedData;
07f3db
+import org.bouncycastle.cms.CMSTypedData;
07f3db
 import org.bouncycastle.cms.CMSSignedDataGenerator;
07f3db
+import org.bouncycastle.operator.ContentSigner;
07f3db
+import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
07f3db
+import org.bouncycastle.cms.jcajce.JcaSignerInfoGeneratorBuilder;
07f3db
+import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder;
07f3db
+import org.bouncycastle.operator.OperatorCreationException;
07f3db
 import org.jboss.resteasy.security.BouncyIntegration;
07f3db
 import org.jboss.resteasy.specimpl.MultivaluedMapImpl;
07f3db
 import org.jboss.resteasy.spi.WriterException;
07f3db
@@ -25,6 +31,7 @@ import java.lang.reflect.Type;
07f3db
 import java.security.NoSuchAlgorithmException;
07f3db
 import java.security.NoSuchProviderException;
07f3db
 import java.security.cert.X509Certificate;
07f3db
+import java.security.cert.CertificateEncodingException;
07f3db
 
07f3db
 /**
07f3db
  * @author Bill Burke
07f3db
@@ -70,7 +77,7 @@ public class PKCS7SignatureWriter implem
07f3db
       }
07f3db
    }
07f3db
 
07f3db
-   public static byte[] sign(Providers providers, SignedOutput out) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, CMSException
07f3db
+   public static byte[] sign(Providers providers, SignedOutput out) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, CMSException, OperatorCreationException, CertificateEncodingException
07f3db
    {
07f3db
       ByteArrayOutputStream bodyOs = new ByteArrayOutputStream();
07f3db
       MessageBodyWriter writer = providers.getMessageBodyWriter(out.getType(), out.getGenericType(), null, out.getMediaType());
07f3db
@@ -82,11 +89,18 @@ public class PKCS7SignatureWriter implem
07f3db
       bodyHeaders.add("Content-Type",  out.getMediaType().toString());
07f3db
       writer.writeTo(out.getEntity(), out.getType(), out.getGenericType(), null, out.getMediaType(), bodyHeaders, bodyOs);
07f3db
       CMSSignedDataGenerator signGen = new CMSSignedDataGenerator();
07f3db
-      signGen.addSigner(out.getPrivateKey(), (X509Certificate)out.getCertificate(), CMSSignedDataGenerator.DIGEST_SHA1);
07f3db
+
07f3db
+      ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(out.getPrivateKey());
07f3db
+      signGen.addSignerInfoGenerator(
07f3db
+               new JcaSignerInfoGeneratorBuilder(
07f3db
+                    new JcaDigestCalculatorProviderBuilder().setProvider("BC").build())
07f3db
+                    .build(sha1Signer, (X509Certificate)out.getCertificate()));
07f3db
+
07f3db
+      //signGen.addSigner(out.getPrivateKey(), (X509Certificate)out.getCertificate(), CMSSignedDataGenerator.DIGEST_SHA1);
07f3db
       //signGen.addCertificatesAndCRLs(certs);
07f3db
-      CMSProcessable content = new CMSProcessableByteArray(bodyOs.toByteArray());
07f3db
+      CMSTypedData content = new CMSProcessableByteArray(bodyOs.toByteArray());
07f3db
 
07f3db
-      CMSSignedData signedData = signGen.generate(content, true, "BC");
07f3db
+      CMSSignedData signedData = signGen.generate(content, true);
07f3db
       return signedData.getEncoded();
07f3db
    }
07f3db
 }