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

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