[pdfbox] build fix for bouncycastle 1.50 (rhbz#1100445)

gil gil at fedoraproject.org
Fri Sep 26 16:37:19 UTC 2014


commit 3f07aee7aad9acf4af04477b261a016195e0d13a
Author: gil <puntogil at libero.it>
Date:   Fri Sep 26 18:37:02 2014 +0200

    build fix for bouncycastle 1.50 (rhbz#1100445)

 pdfbox-1.8.5-port-to-bouncycastle1.50.patch |   88 ++++++++++++
 pdfbox.spec                                 |  200 +++++++++-----------------
 2 files changed, 157 insertions(+), 131 deletions(-)
---
diff --git a/pdfbox-1.8.5-port-to-bouncycastle1.50.patch b/pdfbox-1.8.5-port-to-bouncycastle1.50.patch
new file mode 100644
index 0000000..1e64d03
--- /dev/null
+++ b/pdfbox-1.8.5-port-to-bouncycastle1.50.patch
@@ -0,0 +1,88 @@
+--- pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java	2014-04-28 19:37:18.000000000 +0200
++++ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java-gil	2014-09-26 01:14:24.868807871 +0200
+@@ -27,6 +27,7 @@
+ import java.security.MessageDigest;
+ import java.security.NoSuchAlgorithmException;
+ import java.security.NoSuchProviderException;
++import java.security.PrivateKey;
+ import java.security.SecureRandom;
+ import java.security.Security;
+ import java.security.cert.X509Certificate;
+@@ -37,7 +38,8 @@
+ import javax.crypto.SecretKey;
+ 
+ import org.bouncycastle.asn1.ASN1InputStream;
+-import org.bouncycastle.asn1.DERObject;
++import org.bouncycastle.asn1.ASN1Primitive;
++import org.bouncycastle.asn1.ASN1Set;
+ import org.bouncycastle.asn1.DERObjectIdentifier;
+ import org.bouncycastle.asn1.DEROctetString;
+ import org.bouncycastle.asn1.DEROutputStream;
+@@ -55,6 +57,7 @@
+ import org.bouncycastle.cms.CMSEnvelopedData;
+ import org.bouncycastle.cms.CMSException;
+ import org.bouncycastle.cms.RecipientInformation;
++import org.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipient;
+ import org.bouncycastle.jce.provider.BouncyCastleProvider;
+ import org.apache.pdfbox.cos.COSArray;
+ import org.apache.pdfbox.cos.COSString;
+@@ -183,7 +186,7 @@
+ 	                  if(ri.getRID().match(material.getCertificate()) && !foundRecipient)
+ 	                  {
+ 	                      foundRecipient = true;
+-	                      envelopedData = ri.getContent(material.getPrivateKey(), "BC");
++	                      envelopedData = ri.getContent(new JceKeyTransEnvelopedRecipient((PrivateKey) material.getPrivateKey()).setProvider("BC"));
+ 	                      break;
+ 	                  }
+ 	              }
+@@ -239,10 +242,6 @@
+ 	      {
+ 	          throw new CryptographyException(e);
+ 	      }
+-	      catch(NoSuchProviderException e)
+-	      {
+-	          throw new CryptographyException(e);
+-	      }
+ 	      catch(NoSuchAlgorithmException e)
+ 	      {
+ 	          throw new CryptographyException(e);
+@@ -309,7 +308,7 @@
+                 pkcs7input[22] = two;
+                 pkcs7input[23] = one;
+ 
+-                DERObject obj = createDERForRecipient(pkcs7input, certificate);
++                ASN1Primitive obj = createDERForRecipient(pkcs7input, (X509Certificate)certificate);
+ 
+                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ 
+@@ -376,7 +375,7 @@
+ 
+     }
+ 
+-    private DERObject createDERForRecipient(byte[] in, X509Certificate cert)
++    private ASN1Primitive createDERForRecipient(byte[] in, X509Certificate cert)
+         throws IOException,
+                GeneralSecurityException
+     {
+@@ -387,7 +386,7 @@
+         AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
+         ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
+         ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
+-        DERObject derobject = asn1inputstream.readObject();
++        ASN1Primitive derobject = asn1inputstream.readObject();
+         KeyGenerator keygenerator = KeyGenerator.getInstance(s);
+         keygenerator.init(128);
+         SecretKey secretkey = keygenerator.generateKey();
+@@ -400,10 +399,10 @@
+         AlgorithmIdentifier algorithmidentifier = new AlgorithmIdentifier(new DERObjectIdentifier(s), derobject);
+         EncryptedContentInfo encryptedcontentinfo =
+             new EncryptedContentInfo(PKCSObjectIdentifiers.data, algorithmidentifier, deroctetstring);
+-        EnvelopedData env = new EnvelopedData(null, derset, encryptedcontentinfo, null);
++        EnvelopedData env = new EnvelopedData(null, derset, encryptedcontentinfo, (ASN1Set) null);
+         ContentInfo contentinfo =
+             new ContentInfo(PKCSObjectIdentifiers.envelopedData, env);
+-        return contentinfo.getDERObject();
++        return contentinfo.toASN1Primitive();
+     }
+ 
+     private KeyTransRecipientInfo computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0)
diff --git a/pdfbox.spec b/pdfbox.spec
index 6201626..e8d18e8 100644
--- a/pdfbox.spec
+++ b/pdfbox.spec
@@ -1,9 +1,7 @@
 Name:           pdfbox
 Version:        1.8.5
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Java library for working with PDF documents
-
-Group:          Development/Libraries
 License:        ASL 2.0
 URL:            http://pdfbox.apache.org/
 Source0:        http://www.apache.org/dist/pdfbox/%{version}/%{name}-%{version}-src.zip
@@ -11,11 +9,9 @@ Source0:        http://www.apache.org/dist/pdfbox/%{version}/%{name}-%{version}-
 Patch0:         %{name}-nodownload.patch
 #Use sysytem bitream-vera-sans-fonts instead of bundled fonts
 Patch1:         %{name}-1.2.0-bitstream.patch
-# Be able to skip testImageIOUtils
-# https://issues.apache.org/jira/browse/PDFBOX-2084
-Patch2:         pdfbox-testImageIOUtils.patch
 
-BuildRequires:  jpackage-utils
+Patch3:         pdfbox-1.8.5-port-to-bouncycastle1.50.patch
+
 BuildRequires:  ant
 BuildRequires:  maven-local
 BuildRequires:  maven-install-plugin
@@ -24,6 +20,7 @@ BuildRequires:  apache-commons-logging
 BuildRequires:  apache-rat-plugin
 BuildRequires:  bitstream-vera-sans-fonts
 BuildRequires:  bouncycastle-mail
+#BuildRequires:  bouncycastle-pkix
 BuildRequires:  cobertura-maven-plugin
 BuildRequires:  fontconfig
 BuildRequires:  icu4j
@@ -35,17 +32,12 @@ BuildRequires:  lucene
 BuildRequires:  lucene-demo >= 2.4.1
 %endif
 BuildRequires:  pcfi
+BuildRequires:  log4j12
 
 BuildArch:      noarch
 
-Requires:       jpackage-utils
 Requires:       java >= 1:1.6.0
 Requires:       bitstream-vera-sans-fonts
-Requires:       bouncycastle-mail
-Requires:       fontbox
-Requires:       icu4j
-Requires:       apache-commons-logging
-Requires:       jempbox
 
 Obsoletes:      %{name}-app <= 1.6.0-4
 Provides:       %{name}-app = %{version}-%{release}
@@ -57,20 +49,14 @@ existing documents and the ability to extract content from documents. Apache
 PDFBox also includes several command line utilities. Apache PDFBox is
 published under the Apache License v2.0.
 
-
 %package examples
 Summary:        Examples for %{name}
-Group:          Documentation
-Requires:       jpackage-utils
 
 %description examples
 This package contains examples for %{name}.
 
-
 %package javadoc
-Summary:        Javadocs for %{name}
-Group:          Documentation
-Requires:       jpackage-utils
+Summary:        Javadoc for %{name}
 Provides:       fontbox-javadoc = %{version}-%{release}
 Obsoletes:      fontbox-javadoc < %{version}-%{release}
 Provides:       jempbox-javadoc = %{version}-%{release}
@@ -79,55 +65,36 @@ Obsoletes:      jempbox-javadoc < %{version}-%{release}
 %description javadoc
 This package contains the API documentation for %{name}.
 
-
 %package ant
 Summary:        Apache PDFBox for Ant
-Group:          Development/Libraries
-Requires:       %{name} = %{version}-%{release}
-Requires:       ant
 
 %description ant
 %{summary}.
 
-
 %package -n fontbox
 Summary:        Apache FontBox
-Group:          Development/Libraries
-Requires:       %{name} = %{version}-%{release}
-Requires:       junit
 
 %description -n fontbox
 FontBox is a Java library used to obtain low level information from font
 files. FontBox is a subproject of Apache PDFBox.
 
-
 %package -n jempbox
 Summary:        Apache JempBox
-Group:          Development/Libraries
-Requires:       %{name} = %{version}-%{release}
-Requires:       junit
 
 %description -n jempbox
 JempBox is an open source Java library that implements Adobe's XMP(TM)
 specification. JempBox is a subproject of Apache PDFBox.
 
-
 %package -n preflight
 Summary:        Apache Preflight
-Group:          Development/Libraries
-Requires:       %{name} = %{version}-%{release}
-Requires:       xmpbox = %{version}-%{release}
 
 %description -n preflight
 The Apache Preflight library is an open source Java tool that implements 
 a parser compliant with the ISO-19005 (PDF/A) specification. Preflight is a 
 subproject of Apache PDFBox.
 
-
 %package -n xmpbox
 Summary:        Apache XmpBox
-Group:          Development/Libraries
-Requires:       %{name} = %{version}-%{release}
 
 %description -n xmpbox
 The Apache XmpBox library is an open source Java tool that implements Adobe's
@@ -135,42 +102,36 @@ XMP(TM) specification.  It can be used to parse, validate and create xmp
 contents.  It is mainly used by subproject preflight of Apache PDFBox. 
 XmpBox is a subproject of Apache PDFBox.
 
-
-# Not compatible with lucene 3.6
-%if 0%{?fedora} < 18
-%package lucene
-Summary:        Apache PDFBox for Lucene
-Group:          Development/Libraries
-Requires:       %{name} = %{version}-%{release}
-%if 0%{?fedora} >= 18
-Requires:       lucene
-%else
-Requires:       lucene-demo >= 2.4.1
-%endif
-
-%description lucene
-%{summary}.
-%endif
-
-
 %prep
 %setup -q
 %patch0 -p1 -b .nodownload
 %patch1 -p1 -b .bitstream
-%patch2 -p1 -b .testImageIOUtils
+
 # Skip testImageIOUtils
+# https://issues.apache.org/jira/browse/PDFBOX-2084
 sed -i -e "/TestImageIOUtils.java/d" pdfbox/pom.xml
 # Remove unpackaged deps for the above tests
 %pom_remove_dep com.levigo.jbig2:levigo-jbig2-imageio pdfbox
 %pom_remove_dep net.java.dev.jai-imageio:jai-imageio-core-standalone pdfbox
-#Disable lucene, not compatible with lucene 3
+rm -rf pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java
+sed -i -e /TestImageIOUtils/d pdfbox/src/test/java/org/apache/pdfbox/TestAll.java
+
+%pom_remove_dep javax.activation:activation preflight
+
+%pom_disable_module war
+
+sed -i.ant "s|<artifactId>ant-nodeps</artifactId>|<artifactId>ant</artifactId>|" pom.xml */pom.xml
+
+sed -i.log4j12 "s|<version>1.2.12</version>|<version>1.2.17</version>|" preflight/pom.xml
+
+#Disable lucene, not compatible with lucene 3.6
 %pom_disable_module lucene
 #Use jdk16 version of bcprov
 sed -i -e s/jdk15/jdk16/g */pom.xml
 # Don't build app (it's just a bundle of everything)
 sed -i -e /app/d pom.xml
-find -name '*.class' -exec rm -f '{}' \;
-find -name '*.jar' -exec rm -f '{}' \;
+find -name '*.class' -delete
+find -name '*.jar' -delete
 #Fix line endings
 sed -i -e 's|\r||' RELEASE-NOTES.txt
 #Remove META-INF file that does not exist
@@ -178,91 +139,68 @@ sed -i -e '/META-INF/d' pdfbox/pom.xml
 #Remove included fonts
 rm -r pdfbox/src/main/resources/org/apache/pdfbox/resources/ttf
 
+%pom_add_dep org.bouncycastle:bcpkix-jdk15on:1.50 %{name}
+%patch3 -p0 -b .bouncycastle1.50
 
 %build
-mvn-rpmbuild -Dadobefiles.jar=%{_javadir}/pcfi/pcfi.jar install javadoc:aggregate
-
+# install all libraries in _javadir
+# NOTE: current guideline require all libraries must be installed in _javadir/%%name when JARs are > 2
+%mvn_file :jempbox jempbox
+%mvn_file :%{name} %{name}
+%mvn_file :%{name}-ant %{name}-ant
+%mvn_file :%{name}-examples %{name}-examples
+%mvn_file :preflight preflight
+%mvn_file :xmpbox xmpbox
+%mvn_file :fontbox fontbox
+
+# Merge paret poms in main package
+%mvn_package :%{name} %{name}
+%mvn_package :%{name}-parent %{name}
+%mvn_package :%{name}-reactor %{name}
+
+%mvn_package :fontbox fontbox
+%mvn_package :jempbox jempbox
+%mvn_package :preflight preflight
+%mvn_package :xmpbox xmpbox
+
+%mvn_build -s -- -Dadobefiles.jar=$(build-classpath pcfi)
 
 %install
-mkdir -p $RPM_BUILD_ROOT%{_javadir}
-mkdir -p $RPM_BUILD_ROOT%{_javadocdir}
-mkdir -p $RPM_BUILD_ROOT%{_mavenpomdir}
+%mvn_install
 
-for jar in */target/*.jar
-do
-  dir=$(dirname $jar)
-  target=$(dirname $dir)
-  jarname=$target
-  [ -f ${dir}/%{name}-${target}-%{version}.jar ] && jarname=%{name}-${target}
+#TODO - install/ship war
 
-  cp -p ${dir}/${jarname}-%{version}.jar \
-    $RPM_BUILD_ROOT%{_javadir}/${jarname}.jar
+%files -f .mfiles-%{name}
+%doc LICENSE.txt NOTICE.txt README.txt RELEASE-NOTES.txt
 
-  cp -p ${target}/pom.xml $RPM_BUILD_ROOT%{_mavenpomdir}/JPP-${jarname}.pom
-  %add_maven_depmap JPP-${jarname}.pom ${jarname}.jar
-done
+%files examples -f .mfiles-%{name}-examples
+%doc LICENSE.txt NOTICE.txt
 
-# Javadocs
-cp -rp target/site/apidocs $RPM_BUILD_ROOT%{_javadocdir}/%{name}
+%files javadoc -f .mfiles-javadoc
+%doc LICENSE.txt NOTICE.txt
 
-#Parent
-cp -p parent/pom.xml $RPM_BUILD_ROOT%{_mavenpomdir}/JPP-pdfbox-parent.pom
-%add_maven_depmap JPP-pdfbox-parent.pom
+%files ant -f .mfiles-%{name}-ant
+%doc LICENSE.txt NOTICE.txt
 
-#TODO - install/ship war
+%files -n fontbox -f .mfiles-fontbox
+%doc LICENSE.txt NOTICE.txt
 
+%files -n jempbox -f .mfiles-jempbox
+%doc LICENSE.txt NOTICE.txt
 
-%files
-%doc LICENSE.txt NOTICE.txt README.txt RELEASE-NOTES.txt
-%{_javadir}/%{name}.jar
-%{_mavenpomdir}/JPP-%{name}.pom
-%{_mavenpomdir}/JPP-%{name}-parent.pom
-%{_mavendepmapfragdir}/%{name}
-
-%files examples
-%doc LICENSE.txt
-%{_javadir}/%{name}-examples.jar
-%{_mavenpomdir}/JPP-%{name}-examples.pom
-
-%files javadoc
-%doc LICENSE.txt
-%{_javadocdir}/%{name}
-
-%files ant
-%doc LICENSE.txt
-%{_javadir}/%{name}-ant.jar
-%{_mavenpomdir}/JPP-%{name}-ant.pom
-
-%files -n fontbox
-%doc LICENSE.txt
-%{_javadir}/fontbox.jar
-%{_mavenpomdir}/JPP-fontbox.pom
-
-%files -n jempbox
-%doc LICENSE.txt
-%{_javadir}/jempbox.jar
-%{_mavenpomdir}/JPP-jempbox.pom
-
-%files -n preflight
-%doc LICENSE.txt
-%{_javadir}/preflight.jar
-%{_mavenpomdir}/JPP-preflight.pom
-
-%files -n xmpbox
-%doc LICENSE.txt
-%{_javadir}/xmpbox.jar
-%{_mavenpomdir}/JPP-xmpbox.pom
-
-# Not compatible with lucene 3.6
-%if 0%{?fedora} < 18
-%files lucene
-%doc LICENSE.txt
-%{_javadir}/%{name}-lucene.jar
-%{_mavenpomdir}/JPP-%{name}-lucene.pom
-%endif
+%files -n preflight -f .mfiles-preflight
+%doc LICENSE.txt NOTICE.txt
 
+%files -n xmpbox -f .mfiles-xmpbox
+%doc LICENSE.txt NOTICE.txt
 
 %changelog
+* Fri Sep 26 2014 gil cattaneo <puntogil at libero.it> 1.8.5-3
+- build fix for bouncycastle 1.50 (rhbz#1100445)
+- adapt to current guideline
+- remove lucene sub package
+- force log4j12 usage
+
 * Fri Jun 06 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.8.5-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
 


More information about the scm-commits mailing list