You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2023/05/20 12:10:08 UTC
svn commit: r1909949 - in /pdfbox/trunk: debugger/src/main/java/org/apache/pdfbox/debugger/ examples/src/main/java/org/apache/pdfbox/examples/printing/ examples/src/main/java/org/apache/pdfbox/examples/signature/ examples/src/main/java/org/apache/pdfbo...
Author: tilman
Date: Sat May 20 12:10:07 2023
New Revision: 1909949
URL: http://svn.apache.org/viewvc?rev=1909949&view=rev
Log:
PDFBOX-5607: replace deprecated URL constructor
Modified:
pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/printing/OpaquePDFRenderer.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignedTimeStamp.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/ValidationTimeStamp.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CRLVerifier.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/OcspHelper.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java
pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java
pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
pdfbox/trunk/io/src/test/java/org/apache/pdfbox/io/RandomAccessReadBufferTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSIncrement.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormFlattenTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormFromAnnotsTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/TestRadioButtons.java
Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java (original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java Sat May 20 12:10:07 2023
@@ -38,7 +38,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.lang.reflect.Method;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@@ -528,7 +529,7 @@ public class PDFDebugger extends JFrame
{
readPDFurl(urlString, "");
}
- catch (IOException e)
+ catch (IOException | URISyntaxException e)
{
throw new RuntimeException(e);
}
@@ -550,7 +551,7 @@ public class PDFDebugger extends JFrame
readPDFFile(currentFilePath, "");
}
}
- catch (IOException e)
+ catch (IOException | URISyntaxException e)
{
new ErrorDialog(e).setVisible(true);
}
@@ -707,7 +708,7 @@ public class PDFDebugger extends JFrame
{
readPDFFile(filename, "");
}
- catch (IOException e)
+ catch (IOException | URISyntaxException e)
{
new ErrorDialog(e).setVisible(true);
}
@@ -774,7 +775,7 @@ public class PDFDebugger extends JFrame
}
}
}
- catch (IOException e)
+ catch (IOException | URISyntaxException e)
{
new ErrorDialog(e).setVisible(true);
}
@@ -1333,13 +1334,13 @@ public class PDFDebugger extends JFrame
}
}
- private void readPDFFile(String filePath, String password) throws IOException
+ private void readPDFFile(String filePath, String password) throws IOException, URISyntaxException
{
File file = new File(filePath);
readPDFFile(file, password);
}
- private void readPDFFile(final File file, String password) throws IOException
+ private void readPDFFile(final File file, String password) throws IOException, URISyntaxException
{
if( document != null )
{
@@ -1386,8 +1387,9 @@ public class PDFDebugger extends JFrame
}
addRecentFileItems();
}
-
- private void readPDFurl(final String urlString, String password) throws IOException
+
+ private void readPDFurl(final String urlString, String password)
+ throws IOException, URISyntaxException
{
if (document != null)
{
@@ -1404,11 +1406,11 @@ public class PDFDebugger extends JFrame
DocumentOpener documentOpener = new DocumentOpener(password)
{
@Override
- PDDocument open() throws IOException
+ PDDocument open() throws IOException, URISyntaxException
{
long t0 = System.nanoTime();
PDDocument doc = Loader.loadPDF(RandomAccessReadBuffer
- .createBufferFromStream(new URL(urlString).openStream()), password);
+ .createBufferFromStream(new URI(urlString).toURL().openStream()), password);
long t1 = System.nanoTime();
long ms = TimeUnit.MILLISECONDS.convert(t1 - t0, TimeUnit.NANOSECONDS);
LOG.info("Parsed in " + ms + " ms");
@@ -1433,7 +1435,7 @@ public class PDFDebugger extends JFrame
}
addRecentFileItems();
}
-
+
public void initTree()
{
TreeStatus treeStatus = new TreeStatus(document.getDocument().getTrailer());
@@ -1484,8 +1486,9 @@ public class PDFDebugger extends JFrame
*
* @return the PDDocument instance
* @throws IOException Cannot read document
+ * @throws URISyntaxException
*/
- abstract PDDocument open() throws IOException;
+ abstract PDDocument open() throws IOException, URISyntaxException;
/**
* Call this!
@@ -1493,7 +1496,7 @@ public class PDFDebugger extends JFrame
* @return the PDDocument instance
* @throws IOException Cannot read document
*/
- final PDDocument parse() throws IOException
+ final PDDocument parse() throws IOException, URISyntaxException
{
while (true)
{
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/printing/OpaquePDFRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/printing/OpaquePDFRenderer.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/printing/OpaquePDFRenderer.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/printing/OpaquePDFRenderer.java Sat May 20 12:10:07 2023
@@ -20,7 +20,8 @@ import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.IOException;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.List;
import javax.print.PrintServiceLookup;
import org.apache.commons.logging.Log;
@@ -64,15 +65,15 @@ import org.apache.pdfbox.rendering.PageD
public class OpaquePDFRenderer extends PDFRenderer
{
- public static void main(String[] args) throws IOException, PrinterException
+ public static void main(String[] args) throws IOException, PrinterException, URISyntaxException
{
// PDF from the QZ Tray project, who reported this problem.
// Also test with
// https://github.com/qzind/tray/files/11432463/sample_file-1.pdf
// (second page)
try (PDDocument doc = Loader.loadPDF(RandomAccessReadBuffer.createBufferFromStream(
- new URL("https://github.com/qzind/tray/files/1749977/test.pdf")
- .openStream())))
+ new URI("https://github.com/qzind/tray/files/1749977/test.pdf")
+ .toURL().openStream())))
{
PDFRenderer renderer = new OpaquePDFRenderer(doc);
Printable printable = new PDFPrintable(doc, Scaling.SCALE_TO_FIT, false, 0, true, renderer);
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java Sat May 20 12:10:07 2023
@@ -22,14 +22,20 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+
+import java.net.URISyntaxException;
+
import java.nio.file.Files;
+
import java.security.NoSuchAlgorithmException;
+
import java.util.Arrays;
import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
import org.apache.pdfbox.util.Hex;
+
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.CMSSignedData;
@@ -63,8 +69,9 @@ public class CreateEmbeddedTimeStamp
*
* @param file the PDF file to sign and to overwrite
* @throws IOException
+ * @throws URISyntaxException
*/
- public void embedTimeStamp(File file) throws IOException
+ public void embedTimeStamp(File file) throws IOException, URISyntaxException
{
embedTimeStamp(file, file);
}
@@ -75,8 +82,9 @@ public class CreateEmbeddedTimeStamp
* @param inFile The pdf file possibly containing signatures
* @param outFile Where the changed document will be saved
* @throws IOException
+ * @throws URISyntaxException
*/
- public void embedTimeStamp(File inFile, File outFile) throws IOException
+ public void embedTimeStamp(File inFile, File outFile) throws IOException, URISyntaxException
{
if (inFile == null || !inFile.exists())
{
@@ -97,8 +105,9 @@ public class CreateEmbeddedTimeStamp
* @param inFile The existing PDF file
* @param outFile Where the new file will be written to
* @throws IOException
+ * @throws URISyntaxException
*/
- private void processTimeStamping(File inFile, File outFile) throws IOException
+ private void processTimeStamping(File inFile, File outFile) throws IOException, URISyntaxException
{
try
{
@@ -127,9 +136,10 @@ public class CreateEmbeddedTimeStamp
* @throws IOException
* @throws CMSException
* @throws NoSuchAlgorithmException
+ * @throws URISyntaxException
*/
private void processRelevantSignatures(byte[] documentBytes)
- throws IOException, CMSException, NoSuchAlgorithmException
+ throws IOException, CMSException, NoSuchAlgorithmException, URISyntaxException
{
signature = SigUtils.getLastRelevantSignature(document);
if (signature == null)
@@ -184,7 +194,7 @@ public class CreateEmbeddedTimeStamp
output.write(docBytes, byteRange[2] - 1, byteRange[3] + 1);
}
- public static void main(String[] args) throws IOException
+ public static void main(String[] args) throws IOException, URISyntaxException
{
if (args.length != 3)
{
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java Sat May 20 12:10:07 2023
@@ -18,6 +18,7 @@ package org.apache.pdfbox.examples.signa
import java.io.IOException;
import java.io.InputStream;
+import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -149,7 +150,7 @@ public abstract class CreateSignatureBas
}
return signedData.getEncoded();
}
- catch (GeneralSecurityException | CMSException | OperatorCreationException e)
+ catch (GeneralSecurityException | CMSException | OperatorCreationException | URISyntaxException e)
{
throw new IOException(e);
}
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignedTimeStamp.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignedTimeStamp.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignedTimeStamp.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignedTimeStamp.java Sat May 20 12:10:07 2023
@@ -22,6 +22,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.net.URISyntaxException;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.logging.Log;
@@ -134,7 +135,7 @@ public class CreateSignedTimeStamp imple
validation = new ValidationTimeStamp(tsaUrl);
return validation.getTimeStampToken(content);
}
- catch (NoSuchAlgorithmException e)
+ catch (NoSuchAlgorithmException | URISyntaxException e)
{
LOG.error("Hashing-Algorithm not found for TimeStamping", e);
}
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java Sat May 20 12:10:07 2023
@@ -20,6 +20,8 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
@@ -362,12 +364,13 @@ public class SigUtils
*
* @throws GeneralSecurityException
* @throws IOException
+ * @throws URISyntaxException
*/
public static X509Certificate getTsaCertificate(String tsaUrl)
- throws GeneralSecurityException, IOException
+ throws GeneralSecurityException, IOException, URISyntaxException
{
MessageDigest digest = MessageDigest.getInstance("SHA-256");
- TSAClient tsaClient = new TSAClient(new URL(tsaUrl), null, null, digest);
+ TSAClient tsaClient = new TSAClient(new URI(tsaUrl).toURL(), null, null, digest);
InputStream emptyStream = new ByteArrayInputStream(new byte[0]);
TimeStampToken timeStampToken = tsaClient.getTimeStampToken(emptyStream);
return getCertificateFromTimeStampToken(timeStampToken);
@@ -420,10 +423,11 @@ public class SigUtils
* @param urlString
* @return
* @throws IOException
+ * @throws URISyntaxException
*/
- public static InputStream openURL(String urlString) throws IOException
+ public static InputStream openURL(String urlString) throws IOException, URISyntaxException
{
- URL url = new URL(urlString);
+ URL url = new URI(urlString).toURL();
if (!urlString.startsWith("http"))
{
// so that ftp is still supported
@@ -445,7 +449,7 @@ public class SigUtils
// change this code if you want to be more flexible (but think about security!)
LOG.info("redirection to " + location + " followed");
con.disconnect();
- con = (HttpURLConnection) new URL(location).openConnection();
+ con = (HttpURLConnection) new URI(location).toURL().openConnection();
}
else
{
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/ValidationTimeStamp.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/ValidationTimeStamp.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/ValidationTimeStamp.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/ValidationTimeStamp.java Sat May 20 12:10:07 2023
@@ -21,7 +21,8 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
@@ -56,13 +57,15 @@ public class ValidationTimeStamp
* @param tsaUrl The url where TS-Request will be done.
* @throws NoSuchAlgorithmException
* @throws MalformedURLException
+ * @throws java.net.URISyntaxException
*/
- public ValidationTimeStamp(String tsaUrl) throws NoSuchAlgorithmException, MalformedURLException
+ public ValidationTimeStamp(String tsaUrl)
+ throws NoSuchAlgorithmException, MalformedURLException, URISyntaxException
{
if (tsaUrl != null)
{
MessageDigest digest = MessageDigest.getInstance("SHA-256");
- this.tsaClient = new TSAClient(new URL(tsaUrl), null, null, digest);
+ this.tsaClient = new TSAClient(new URI(tsaUrl).toURL(), null, null, digest);
}
}
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CRLVerifier.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CRLVerifier.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CRLVerifier.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CRLVerifier.java Sat May 20 12:10:07 2023
@@ -22,6 +22,7 @@ package org.apache.pdfbox.examples.signa
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.security.cert.CRLException;
import java.security.cert.CertificateException;
@@ -234,7 +235,7 @@ public final class CRLVerifier
*/
private static X509CRL downloadCRL(String crlURL) throws IOException,
CertificateException, CRLException,
- CertificateVerificationException, NamingException
+ CertificateVerificationException, NamingException, URISyntaxException
{
if (crlURL.startsWith("http://") || crlURL.startsWith("https://")
|| crlURL.startsWith("ftp://"))
@@ -291,7 +292,7 @@ public final class CRLVerifier
* http://crl.infonotary.com/crl/identity-ca.crl
*/
public static X509CRL downloadCRLFromWeb(String crlURL)
- throws IOException, CertificateException, CRLException
+ throws IOException, CertificateException, CRLException, URISyntaxException
{
try (InputStream crlStream = SigUtils.openURL(crlURL))
{
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java Sat May 20 12:10:07 2023
@@ -21,6 +21,7 @@ package org.apache.pdfbox.examples.signa
import java.io.IOException;
import java.io.InputStream;
+import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
import java.security.PublicKey;
@@ -188,7 +189,8 @@ public final class CertificateVerifier
{
throw cvex;
}
- catch (IOException | GeneralSecurityException | RevokedCertificateException | OCSPException ex)
+ catch (IOException | URISyntaxException |
+ GeneralSecurityException | RevokedCertificateException | OCSPException ex)
{
throw new CertificateVerificationException(
"Error verifying the certificate: "
@@ -200,7 +202,7 @@ public final class CertificateVerifier
Set<X509Certificate> additionalCerts,
Date signDate)
throws IOException, CertificateVerificationException, OCSPException,
- RevokedCertificateException, GeneralSecurityException
+ RevokedCertificateException, GeneralSecurityException, URISyntaxException
{
if (isSelfSigned(cert))
{
@@ -225,7 +227,7 @@ public final class CertificateVerifier
private static void checkRevocationsWithIssuer(X509Certificate cert, X509Certificate issuerCert,
Set<X509Certificate> additionalCerts, Date signDate)
throws OCSPException, CertificateVerificationException, RevokedCertificateException,
- GeneralSecurityException, IOException
+ GeneralSecurityException, IOException, URISyntaxException
{
// Try checking the certificate through OCSP (faster than CRL)
String ocspURL = extractOCSPURL(cert);
@@ -337,7 +339,7 @@ public final class CertificateVerifier
altCerts.forEach(altCert -> resultSet.add((X509Certificate) altCert));
LOG.info("CA issuers URL: " + altCerts.size() + " certificate(s) downloaded");
}
- catch (IOException ex)
+ catch (IOException | URISyntaxException ex)
{
LOG.warn(urlString + " failure: " + ex.getMessage(), ex);
}
@@ -450,11 +452,13 @@ public final class CertificateVerifier
* @param additionalCerts
* @throws RevokedCertificateException
* @throws IOException
+ * @throws URISyntaxException
* @throws OCSPException
* @throws CertificateVerificationException
*/
private static void verifyOCSP(OcspHelper ocspHelper, Set<X509Certificate> additionalCerts)
- throws RevokedCertificateException, IOException, OCSPException, CertificateVerificationException
+ throws RevokedCertificateException, IOException, OCSPException,
+ CertificateVerificationException, URISyntaxException
{
Date now = Calendar.getInstance().getTime();
OCSPResp ocspResponse;
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/OcspHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/OcspHelper.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/OcspHelper.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/OcspHelper.java Sat May 20 12:10:07 2023
@@ -21,6 +21,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -128,8 +130,10 @@ public class OcspHelper
* @throws IOException
* @throws OCSPException
* @throws RevokedCertificateException
+ * @throws URISyntaxException
*/
- public OCSPResp getResponseOcsp() throws IOException, OCSPException, RevokedCertificateException
+ public OCSPResp getResponseOcsp()
+ throws IOException, OCSPException, RevokedCertificateException, URISyntaxException
{
OCSPResp ocspResponse = performRequest(ocspUrl);
verifyOcspResponse(ocspResponse);
@@ -451,11 +455,13 @@ public class OcspHelper
* @return the OCSPResp, that has been fetched from the ocspUrl
* @throws IOException
* @throws OCSPException
+ * @throws URISyntaxException
*/
- private OCSPResp performRequest(String urlString) throws IOException, OCSPException
+ private OCSPResp performRequest(String urlString)
+ throws IOException, OCSPException, URISyntaxException
{
OCSPReq request = generateOCSPRequest();
- URL url = new URL(urlString);
+ URL url = new URI(urlString).toURL();
HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
try
{
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java Sat May 20 12:10:07 2023
@@ -22,6 +22,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -324,7 +325,7 @@ public class AddValidationInformation
addOcspData(certInfo);
return true;
}
- catch (OCSPException | CertificateProccessingException | IOException e)
+ catch (OCSPException | CertificateProccessingException | IOException | URISyntaxException e)
{
LOG.error("Failed fetching OCSP at " + certInfo.getOcspUrl(), e);
return false;
@@ -348,7 +349,8 @@ public class AddValidationInformation
{
addCrlRevocationInfo(certInfo);
}
- catch (GeneralSecurityException | IOException | RevokedCertificateException | CertificateVerificationException e)
+ catch (GeneralSecurityException | IOException | URISyntaxException |
+ RevokedCertificateException | CertificateVerificationException e)
{
LOG.warn("Failed fetching CRL", e);
throw new IOException(e);
@@ -365,7 +367,7 @@ public class AddValidationInformation
* @throws RevokedCertificateException
*/
private void addOcspData(CertSignatureInformation certInfo) throws IOException, OCSPException,
- CertificateProccessingException, RevokedCertificateException
+ CertificateProccessingException, RevokedCertificateException, URISyntaxException
{
if (ocspChecked.contains(certInfo.getCertificate()))
{
@@ -429,13 +431,14 @@ public class AddValidationInformation
*
* @param certInfo the certificate info, for it to check CRL data.
* @throws IOException
+ * @throws URIs
* @throws RevokedCertificateException
* @throws GeneralSecurityException
* @throws CertificateVerificationException
*/
private void addCrlRevocationInfo(CertSignatureInformation certInfo)
throws IOException, RevokedCertificateException, GeneralSecurityException,
- CertificateVerificationException
+ CertificateVerificationException, URISyntaxException
{
X509CRL crl = CRLVerifier.downloadCRLFromWeb(certInfo.getCrlUrl());
X509Certificate issuerCertificate = certInfo.getIssuerCertificate();
Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java Sat May 20 12:10:07 2023
@@ -20,10 +20,14 @@ package org.apache.pdfbox.examples.signa
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+
+import java.net.URISyntaxException;
+
import java.security.GeneralSecurityException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -35,6 +39,7 @@ import org.apache.pdfbox.examples.signat
import org.apache.pdfbox.examples.signature.cert.CertificateVerifier;
import org.apache.pdfbox.pdmodel.encryption.SecurityProvider;
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
+
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.cms.Attribute;
@@ -296,7 +301,7 @@ public class CertInformationCollector
traverseChain(altIssuerCert, certInfo.alternativeCertChain, maxDepth - 1);
}
}
- catch (IOException | CertificateException e)
+ catch (IOException | URISyntaxException | CertificateException e)
{
LOG.error("Error getting alternative issuer certificate from " + certInfo.issuerUrl, e);
}
Modified: pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java (original)
+++ pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java Sat May 20 12:10:07 2023
@@ -36,6 +36,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.GeneralSecurityException;
@@ -170,6 +171,7 @@ class TestCreateSignature
* Signs a PDF using the "adbe.pkcs7.detached" SubFilter with the SHA-256 digest.
*
* @throws IOException
+ * @throws URISyntaxException
* @throws GeneralSecurityException
* @throws CMSException
* @throws OperatorCreationException
@@ -180,7 +182,7 @@ class TestCreateSignature
@MethodSource("signingTypes")
void testDetachedSHA256(boolean externallySign)
throws IOException, CMSException, OperatorCreationException, GeneralSecurityException,
- TSPException, CertificateVerificationException
+ TSPException, CertificateVerificationException, URISyntaxException
{
// sign PDF
CreateSignature signing = new CreateSignature(keyStore, PASSWORD.toCharArray());
Modified: pdfbox/trunk/io/src/test/java/org/apache/pdfbox/io/RandomAccessReadBufferTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/io/src/test/java/org/apache/pdfbox/io/RandomAccessReadBufferTest.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/io/src/test/java/org/apache/pdfbox/io/RandomAccessReadBufferTest.java (original)
+++ pdfbox/trunk/io/src/test/java/org/apache/pdfbox/io/RandomAccessReadBufferTest.java Sat May 20 12:10:07 2023
@@ -25,7 +25,10 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.net.URL;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
import java.nio.file.Files;
import java.nio.file.Path;
@@ -200,11 +203,11 @@ class RandomAccessReadBufferTest
}
@Test
- void testPDFBOX5111() throws IOException
+ void testPDFBOX5111() throws IOException, URISyntaxException
{
- try (InputStream is = new URL(
+ try (InputStream is = new URI(
"https://issues.apache.org/jira/secure/attachment/13017227/stringwidth.pdf")
- .openStream();
+ .toURL().openStream();
RandomAccessReadBuffer randomAccessSource = new RandomAccessReadBuffer(is))
{
assertEquals(34060, randomAccessSource.length());
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSIncrement.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSIncrement.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSIncrement.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSIncrement.java Sat May 20 12:10:07 2023
@@ -43,7 +43,11 @@ import static org.junit.jupiter.api.Asse
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
+
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
+
import java.util.ConcurrentModificationException;
class TestCOSIncrement
@@ -253,12 +257,13 @@ class TestCOSIncrement
* YTW2VWJQTDAE67PGJT6GS7QSKW3GNUQR.pdf - test that this issues has been resolved.
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testConcurrentModification() throws IOException
+ void testConcurrentModification() throws IOException, URISyntaxException
{
URL pdfLocation =
- new URL("https://issues.apache.org/jira/secure/attachment/12891316/YTW2VWJQTDAE67PGJT6GS7QSKW3GNUQR.pdf");
+ new URI("https://issues.apache.org/jira/secure/attachment/12891316/YTW2VWJQTDAE67PGJT6GS7QSKW3GNUQR.pdf").toURL();
try (PDDocument document = Loader
.loadPDF(RandomAccessReadBuffer.createBufferFromStream(pdfLocation.openStream())))
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java Sat May 20 12:10:07 2023
@@ -270,14 +270,15 @@ class PDFontTest
/**
* Test using broken Type1C font.
*
- * @throws IOException
+ * @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testPDFox5048() throws IOException
+ void testPDFox5048() throws IOException, URISyntaxException
{
try (PDDocument doc = Loader.loadPDF(RandomAccessReadBuffer.createBufferFromStream(
- new URL("https://issues.apache.org/jira/secure/attachment/13017227/stringwidth.pdf")
- .openStream())))
+ new URI("https://issues.apache.org/jira/secure/attachment/13017227/stringwidth.pdf")
+ .toURL().openStream())))
{
PDPage page = doc.getPage(0);
PDFont font = page.getResources().getFont(COSName.getPDFName("F70"));
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormFlattenTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormFlattenTest.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormFlattenTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormFlattenTest.java Sat May 20 12:10:07 2023
@@ -25,7 +25,8 @@ import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
@@ -139,7 +140,8 @@ class PDAcroFormFlattenTest
// disabled as there is a minimal difference which can not be seen visually on ci-builds
// "https://issues.apache.org/jira/secure/attachment/13012242/PDFBOX-4958.pdf,PDFBOX-4958-flattened.pdf"
})
- void testFlatten(String sourceUrl, String targetFileName) throws IOException {
+ void testFlatten(String sourceUrl, String targetFileName) throws IOException, URISyntaxException
+ {
flattenAndCompare(sourceUrl, targetFileName);
}
@@ -168,7 +170,7 @@ class PDAcroFormFlattenTest
}
@Test
- void flattenTestPDFBOX5254() throws IOException
+ void flattenTestPDFBOX5254() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/13005793/f1040sb%20test.pdf";
String targetFileName = "PDFBOX-4889-5254.pdf";
@@ -206,8 +208,10 @@ class PDAcroFormFlattenTest
* Flatten and compare with generated image samples.
*
* @throws IOException
+ * @throws URISyntaxException
*/
- private static void flattenAndCompare(String sourceUrl, String targetFileName) throws IOException
+ private static void flattenAndCompare(String sourceUrl, String targetFileName)
+ throws IOException, URISyntaxException
{
generateSamples(sourceUrl,targetFileName);
@@ -241,8 +245,10 @@ class PDAcroFormFlattenTest
* Generate the sample images to which the PDF will be compared after flatten.
*
* @throws IOException
+ * @throws URISyntaxException
*/
- private static void generateSamples(String sourceUrl, String targetFile) throws IOException
+ private static void generateSamples(String sourceUrl, String targetFile)
+ throws IOException, URISyntaxException
{
getFromUrl(sourceUrl, targetFile);
@@ -267,10 +273,12 @@ class PDAcroFormFlattenTest
* Get a PDF from URL and copy to file for processing.
*
* @throws IOException
+ * @throws URISyntaxException
*/
- private static void getFromUrl(String sourceUrl, String targetFile) throws IOException
+ private static void getFromUrl(String sourceUrl, String targetFile)
+ throws IOException, URISyntaxException
{
- try (InputStream is = new URL(sourceUrl).openStream())
+ try (InputStream is = new URI(sourceUrl).toURL().openStream())
{
Files.copy(is, new File(IN_DIR, targetFile).toPath(), StandardCopyOption.REPLACE_EXISTING);
}
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormFromAnnotsTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormFromAnnotsTest.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormFromAnnotsTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormFromAnnotsTest.java Sat May 20 12:10:07 2023
@@ -21,7 +21,10 @@ import static org.junit.jupiter.api.Asse
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
-import java.net.URL;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
import java.util.HashMap;
import java.util.Map;
@@ -37,6 +40,7 @@ import org.apache.pdfbox.pdmodel.fixup.A
import org.apache.pdfbox.pdmodel.fixup.AcroFormDefaultFixup;
import org.apache.pdfbox.pdmodel.fixup.processor.AcroFormOrphanWidgetsProcessor;
import org.apache.pdfbox.pdmodel.font.PDFont;
+
import org.junit.jupiter.api.Test;
/**
@@ -48,28 +52,29 @@ class PDAcroFormFromAnnotsTest
/**
* PDFBOX-4985 AcroForms entry but empty Fields array
*
- * Using the default get acroform call with error correction
+ * Using the default get AcroForm call with error correction
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testFromAnnots4985DefaultMode() throws IOException
+ void testFromAnnots4985DefaultMode() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/13013354/POPPLER-806.pdf";
String acrobatSourceUrl = "https://issues.apache.org/jira/secure/attachment/13013384/POPPLER-806-acrobat.pdf";
- int numFormFieldsByAcrobat = 0;
+ int numFormFieldsByAcrobat;
try (PDDocument testPdf = Loader.loadPDF(RandomAccessReadBuffer
- .createBufferFromStream(new URL(acrobatSourceUrl).openStream())))
+ .createBufferFromStream(new URI(acrobatSourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
PDAcroForm acroForm = catalog.getAcroForm(null);
numFormFieldsByAcrobat = acroForm.getFields().size();
}
- try (PDDocument testPdf = Loader.loadPDF(RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ try (PDDocument testPdf = Loader.loadPDF(RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
// need to do a low level cos access as the PDModel access will build the AcroForm
@@ -87,18 +92,19 @@ class PDAcroFormFromAnnotsTest
* Using the acroform call with error correction
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testFromAnnots4985CorrectionMode() throws IOException
+ void testFromAnnots4985CorrectionMode() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/13013354/POPPLER-806.pdf";
String acrobatSourceUrl = "https://issues.apache.org/jira/secure/attachment/13013384/POPPLER-806-acrobat.pdf";
- int numFormFieldsByAcrobat = 0;
+ int numFormFieldsByAcrobat;
try (PDDocument testPdf = Loader.loadPDF(RandomAccessReadBuffer
- .createBufferFromStream(new URL(acrobatSourceUrl).openStream())))
+ .createBufferFromStream(new URI(acrobatSourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
PDAcroForm acroForm = catalog.getAcroForm(null);
@@ -106,7 +112,7 @@ class PDAcroFormFromAnnotsTest
}
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
// need to do a low level cos access as the PDModel access will build the AcroForm
@@ -124,17 +130,18 @@ class PDAcroFormFromAnnotsTest
* Using the acroform call without error correction
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testFromAnnots4985WithoutCorrectionMode() throws IOException
+ void testFromAnnots4985WithoutCorrectionMode() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/13013354/POPPLER-806.pdf";
- int numCosFormFields = 0;
+ int numCosFormFields;
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
// need to do a low level cos access as the PDModel access will build the AcroForm
@@ -153,15 +160,16 @@ class PDAcroFormFromAnnotsTest
* With the default correction nothing shall be added
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testFromAnnots3891DontCreateFields() throws IOException
+ void testFromAnnots3891DontCreateFields() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12881055/merge-test.pdf";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
// need to do a low level cos access as the PDModel access will build the AcroForm
@@ -179,21 +187,22 @@ class PDAcroFormFromAnnotsTest
* Special fixup to create fields
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testFromAnnots3891CreateFields() throws IOException
+ void testFromAnnots3891CreateFields() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12881055/merge-test.pdf";
String acrobatSourceUrl = "https://issues.apache.org/jira/secure/attachment/13014447/merge-test-na-acrobat.pdf";
- int numFormFieldsByAcrobat = 0;
+ int numFormFieldsByAcrobat;
// will build the expected fields using the acrobat source document
Map<String, PDField> fieldsByName = new HashMap<>();
try (PDDocument testPdf = Loader.loadPDF(RandomAccessReadBuffer
- .createBufferFromStream(new URL(acrobatSourceUrl).openStream())))
+ .createBufferFromStream(new URI(acrobatSourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
PDAcroForm acroForm = catalog.getAcroForm(null);
@@ -205,7 +214,7 @@ class PDAcroFormFromAnnotsTest
}
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
// need to do a low level cos access as the PDModel access will build the AcroForm
@@ -233,9 +242,10 @@ class PDAcroFormFromAnnotsTest
* which are taken from the widget normal appearance resources
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testFromAnnots3891ValidateFont() throws IOException
+ void testFromAnnots3891ValidateFont() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12881055/merge-test.pdf";
@@ -245,7 +255,7 @@ class PDAcroFormFromAnnotsTest
Map<String, String> fontNames = new HashMap<>();
try (PDDocument testPdf = Loader.loadPDF(RandomAccessReadBuffer
- .createBufferFromStream(new URL(acrobatSourceUrl).openStream())))
+ .createBufferFromStream(new URI(acrobatSourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
PDAcroForm acroForm = catalog.getAcroForm(null);
@@ -268,7 +278,7 @@ class PDAcroFormFromAnnotsTest
}
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
PDAcroForm acroForm = catalog.getAcroForm(new CreateFieldsFixup(testPdf));
@@ -295,14 +305,15 @@ class PDAcroFormFromAnnotsTest
* PDFBOX-3891 null PDFieldFactory.createField
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testFromAnnots3891NullField() throws IOException
+ void testFromAnnots3891NullField() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/13016993/poppler-14433-0.pdf";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
assertDoesNotThrow(() -> catalog.getAcroForm(new CreateFieldsFixup(testPdf)), "Getting the AcroForm shall not throw an exception");
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java Sat May 20 12:10:07 2023
@@ -20,7 +20,9 @@ package org.apache.pdfbox.pdmodel.intera
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import java.io.IOException;
-import java.net.URL;
+
+import java.net.URI;
+import java.net.URISyntaxException;
import org.apache.pdfbox.Loader;
import org.apache.pdfbox.io.RandomAccessReadBuffer;
@@ -46,10 +48,10 @@ class PDAcroFormGenerateAppearancesTest
// PDFBOX-5043 PaperMetaData
"https://issues.apache.org/jira/secure/attachment/13016992/PDFBOX-3891-5.pdf"
})
- void testGetAcroForm(String sourceUrl) throws IOException
+ void testGetAcroForm(String sourceUrl) throws IOException, URISyntaxException
{
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormTest.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormTest.java Sat May 20 12:10:07 2023
@@ -25,7 +25,8 @@ import static org.junit.jupiter.api.Asse
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
@@ -352,14 +353,15 @@ class PDAcroFormTest
* PDFBOX-3777 Illegal Fields definition COSDictionary instead of Array
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testIllegalFieldsDefinition() throws IOException
+ void testIllegalFieldsDefinition() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12866226/D1790B.PDF";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeTest.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDFieldTreeTest.java Sat May 20 12:10:07 2023
@@ -17,7 +17,9 @@
package org.apache.pdfbox.pdmodel.interactive.form;
import java.io.IOException;
-import java.net.URL;
+
+import java.net.URI;
+import java.net.URISyntaxException;
import org.apache.pdfbox.Loader;
import org.apache.pdfbox.io.RandomAccessReadBuffer;
@@ -38,14 +40,15 @@ class PDFieldTreeTest
* PDFBOX-5044 stack overflow
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void test5044() throws IOException
+ void test5044() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/13016994/PDFBOX-4131-0.pdf";
try (PDDocument doc = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDDocumentCatalog catalog = doc.getDocumentCatalog();
PDAcroForm acroForm = catalog.getAcroForm();
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/TestRadioButtons.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/TestRadioButtons.java?rev=1909949&r1=1909948&r2=1909949&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/TestRadioButtons.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/TestRadioButtons.java Sat May 20 12:10:07 2023
@@ -24,7 +24,10 @@ import static org.junit.jupiter.api.Asse
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
-import java.net.URL;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
import java.util.ArrayList;
import java.util.List;
@@ -134,15 +137,16 @@ class TestRadioButtons
* PDFBOX-3656 Radio button field with FLAG_RADIOS_IN_UNISON false
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testPDFBox3656NotInUnison() throws IOException
+ void testPDFBox3656NotInUnison() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton) acroForm.getField("Checking/Savings");
@@ -158,14 +162,15 @@ class TestRadioButtons
* Setting by the first export value shall only select the first radio button
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testPDFBox3656ByValidExportValue() throws IOException
+ void testPDFBox3656ByValidExportValue() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton) acroForm.getField("Checking/Savings");
@@ -184,14 +189,15 @@ class TestRadioButtons
* PDFBOX-3656 Set by invalid export value
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testPDFBox3656ByInvalidExportValue() throws IOException
+ void testPDFBox3656ByInvalidExportValue() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton) acroForm.getField("Checking/Savings");
@@ -223,14 +229,15 @@ class TestRadioButtons
* Setting by the index shall only select the corresponding radio button
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testPDFBox3656ByValidIndex() throws IOException
+ void testPDFBox3656ByValidIndex() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton) acroForm.getField("Checking/Savings");
@@ -252,15 +259,16 @@ class TestRadioButtons
* Setting by the index shall only select the corresponding radio button
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testPDFBox3656ByInvalidIndex() throws IOException
+ void testPDFBox3656ByInvalidIndex() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton) acroForm.getField("Checking/Savings");
@@ -289,14 +297,15 @@ class TestRadioButtons
* PDFBOX-4617 Enable getting selected index
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testPDFBox4617IndexNoneSelected() throws IOException
+ void testPDFBox4617IndexNoneSelected() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton) acroForm.getField("Checking/Savings");
@@ -309,14 +318,15 @@ class TestRadioButtons
* PDFBOX-4617 Enable getting selected index for value being set by option
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testPDFBox4617IndexForSetByOption() throws IOException
+ void testPDFBox4617IndexForSetByOption() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton) acroForm.getField("Checking/Savings");
@@ -330,14 +340,15 @@ class TestRadioButtons
* PDFBOX-4617 Enable getting selected index for value being set by index
*
* @throws IOException
+ * @throws URISyntaxException
*/
@Test
- void testPDFBox4617IndexForSetByIndex() throws IOException
+ void testPDFBox4617IndexForSetByIndex() throws IOException, URISyntaxException
{
String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new URL(sourceUrl).openStream())))
+ RandomAccessReadBuffer.createBufferFromStream(new URI(sourceUrl).toURL().openStream())))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton) acroForm.getField("Checking/Savings");