This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new ed8ad1eb6ac5 camel-pdf: deprecate CamelPdfDecryptionMaterial, which 
nothing reads (#29972)
ed8ad1eb6ac5 is described below

commit ed8ad1eb6ac51633d31bdcbc0b9a24bfb67640c9
Author: dhairya05 <[email protected]>
AuthorDate: Tue Nov 17 18:37:03 2026 +0530

    camel-pdf: deprecate CamelPdfDecryptionMaterial, which nothing reads 
(#29972)
    
    The header is documented as the *Mandatory* header if the PDF document
    is encrypted, but the component never looks it up - PdfProducer reads
    CamelPdfDocument and CamelPdfProtectionPolicy by name and never this
    one, and the only other references to it are two tests that decrypt the
    document themselves with Loader.loadPDF(bytes, userPass) before sending
    it, so the header they set alongside is decoration.
    
    The one place it could be applied loads without a password:
    
        @Converter
        public PDDocument convertToPDF(byte[] bytes) throws Exception {
            return Loader.loadPDF(bytes);
        }
    
    so sending an encrypted PDF as bytes with the documented header fails in
    the type converter with InvalidPasswordException, before the producer
    runs. A PDDocument in the body is already decrypted by whatever loaded
    it, which is why the tests pass.
    
    It looks like a leftover of the PDFBox 1.x API, where the document was
    opened first and decrypted afterwards with
    document.openProtection(decryptionMaterial); PDFBox 2 and 3 take the
    password at load time instead.
    
    Deprecate it with a note saying so.
    
    Four things from review:
    
    1. "never been read" was wrong. PdfProducer did read the header and call
       PDDocument.openProtection(decryptionMaterial) up to Camel 2.20; the
       read went away with CAMEL-11976, which aligned the component on
       PDFBox 2.0.6. So it is "no longer read", with no effect since 2.21.
    2. The description carried the whole deprecation paragraph, and the
       generator appends "Deprecation note: ..." to it, so the catalog gave
       the reason twice; the leading asterisk of *Deprecated.* was also
       stripped, leaving "Deprecated.*" mid-sentence. The description is now
       one short sentence and the reason lives only in deprecationNote.
    3. Added a section to the 4.24 upgrade guide, with the Processor that
       loads an encrypted document with its password.
    4. PdfAppendTest and PdfTextExtractionTest no longer set the header,
       which did nothing there and now warns.
    
    Co-Authored-By: Claude Opus 5 <[email protected]>
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Co-authored-by: Guillaume Nodet - AI Bot <[email protected]>
---
 .../org/apache/camel/catalog/components/pdf.json    |  2 +-
 .../org/apache/camel/component/pdf/pdf.json         |  2 +-
 .../camel/component/pdf/PdfHeaderConstants.java     |  9 ++++++---
 .../apache/camel/component/pdf/PdfAppendTest.java   |  2 --
 .../camel/component/pdf/PdfTextExtractionTest.java  |  6 +-----
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc     | 21 +++++++++++++++++++++
 .../endpoint/dsl/PdfEndpointBuilderFactory.java     |  3 ++-
 7 files changed, 32 insertions(+), 13 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pdf.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pdf.json
index b1c9c6e3869c..349dc587262b 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pdf.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pdf.json
@@ -30,7 +30,7 @@
   "headers": {
     "CamelPdfProtectionPolicy": { "index": 0, "kind": "header", "displayName": 
"", "group": "producer", "label": "", "required": false, "javaType": 
"org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy", "deprecated": false, 
"autowired": false, "secret": false, "description": "Expected type is 
https:\/\/pdfbox.apache.org\/docs\/2.0.13\/javadocs\/org\/apache\/pdfbox\/pdmodel\/encryption\/ProtectionPolicy.html[ProtectionPolicy].
 If specified then PDF document will be encrypted with it.",  [...]
     "CamelPdfDocument": { "index": 1, "kind": "header", "displayName": "", 
"group": "producer", "label": "", "required": false, "javaType": 
"org.apache.pdfbox.pdmodel.PDDocument", "deprecated": false, "autowired": 
false, "secret": false, "description": "Mandatory* header for append operation 
and ignored in all other operations. Expected type is 
https:\/\/pdfbox.apache.org\/docs\/2.0.13\/javadocs\/org\/apache\/pdfbox\/pdmodel\/PDDocument.html[PDDocument].
 Stores PDF document which will be [...]
-    "CamelPdfDecryptionMaterial": { "index": 2, "kind": "header", 
"displayName": "", "group": "producer", "label": "", "required": false, 
"javaType": "org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial", 
"deprecated": false, "autowired": false, "secret": false, "description": 
"Expected type is 
https:\/\/pdfbox.apache.org\/docs\/2.0.13\/javadocs\/org\/apache\/pdfbox\/pdmodel\/encryption\/DecryptionMaterial.html[DecryptionMaterial].
 Mandatory* header if PDF document is encrypted.", "c [...]
+    "CamelPdfDecryptionMaterial": { "index": 2, "kind": "header", 
"displayName": "", "group": "producer", "label": "", "required": false, 
"javaType": "org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial", 
"deprecated": true, "deprecationNote": "No longer read by the component since 
Camel 2.21: PDFBox 2 decrypts at load time via Loader.loadPDF(bytes, password). 
The byte[] converter loads without a password. Decrypt in a Processor before 
the PDF endpoint instead.", "autowired": false,  [...]
     "CamelPdfFilesToMerge": { "index": 3, "kind": "header", "displayName": "", 
"group": "producer", "label": "", "required": false, "javaType": 
"java.util.List<java.lang.Object>", "deprecated": false, "autowired": false, 
"secret": false, "description": "Mandatory* header for merge operation and 
ignored in all other operations. The list of pdf files that will be merged, 
each given as a java.io.File or a java.nio.file.Path.", "constantName": 
"org.apache.camel.component.pdf.PdfHeaderConstan [...]
   },
   "bodyTypes": {
diff --git 
a/components/camel-pdf/src/generated/resources/META-INF/org/apache/camel/component/pdf/pdf.json
 
b/components/camel-pdf/src/generated/resources/META-INF/org/apache/camel/component/pdf/pdf.json
index b1c9c6e3869c..349dc587262b 100644
--- 
a/components/camel-pdf/src/generated/resources/META-INF/org/apache/camel/component/pdf/pdf.json
+++ 
b/components/camel-pdf/src/generated/resources/META-INF/org/apache/camel/component/pdf/pdf.json
@@ -30,7 +30,7 @@
   "headers": {
     "CamelPdfProtectionPolicy": { "index": 0, "kind": "header", "displayName": 
"", "group": "producer", "label": "", "required": false, "javaType": 
"org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy", "deprecated": false, 
"autowired": false, "secret": false, "description": "Expected type is 
https:\/\/pdfbox.apache.org\/docs\/2.0.13\/javadocs\/org\/apache\/pdfbox\/pdmodel\/encryption\/ProtectionPolicy.html[ProtectionPolicy].
 If specified then PDF document will be encrypted with it.",  [...]
     "CamelPdfDocument": { "index": 1, "kind": "header", "displayName": "", 
"group": "producer", "label": "", "required": false, "javaType": 
"org.apache.pdfbox.pdmodel.PDDocument", "deprecated": false, "autowired": 
false, "secret": false, "description": "Mandatory* header for append operation 
and ignored in all other operations. Expected type is 
https:\/\/pdfbox.apache.org\/docs\/2.0.13\/javadocs\/org\/apache\/pdfbox\/pdmodel\/PDDocument.html[PDDocument].
 Stores PDF document which will be [...]
-    "CamelPdfDecryptionMaterial": { "index": 2, "kind": "header", 
"displayName": "", "group": "producer", "label": "", "required": false, 
"javaType": "org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial", 
"deprecated": false, "autowired": false, "secret": false, "description": 
"Expected type is 
https:\/\/pdfbox.apache.org\/docs\/2.0.13\/javadocs\/org\/apache\/pdfbox\/pdmodel\/encryption\/DecryptionMaterial.html[DecryptionMaterial].
 Mandatory* header if PDF document is encrypted.", "c [...]
+    "CamelPdfDecryptionMaterial": { "index": 2, "kind": "header", 
"displayName": "", "group": "producer", "label": "", "required": false, 
"javaType": "org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial", 
"deprecated": true, "deprecationNote": "No longer read by the component since 
Camel 2.21: PDFBox 2 decrypts at load time via Loader.loadPDF(bytes, password). 
The byte[] converter loads without a password. Decrypt in a Processor before 
the PDF endpoint instead.", "autowired": false,  [...]
     "CamelPdfFilesToMerge": { "index": 3, "kind": "header", "displayName": "", 
"group": "producer", "label": "", "required": false, "javaType": 
"java.util.List<java.lang.Object>", "deprecated": false, "autowired": false, 
"secret": false, "description": "Mandatory* header for merge operation and 
ignored in all other operations. The list of pdf files that will be merged, 
each given as a java.io.File or a java.nio.file.Path.", "constantName": 
"org.apache.camel.component.pdf.PdfHeaderConstan [...]
   },
   "bodyTypes": {
diff --git 
a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfHeaderConstants.java
 
b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfHeaderConstants.java
index 51c4c6d9dbbf..68e3cc7ba2e0 100644
--- 
a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfHeaderConstants.java
+++ 
b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfHeaderConstants.java
@@ -34,9 +34,12 @@ public final class PdfHeaderConstants {
     public static final String PDF_DOCUMENT_HEADER_NAME = "CamelPdfDocument";
     @Metadata(description = """
             Expected type is
-            
https://pdfbox.apache.org/docs/2.0.13/javadocs/org/apache/pdfbox/pdmodel/encryption/DecryptionMaterial.html[DecryptionMaterial].
-            *Mandatory* header if PDF document is encrypted.""",
-              javaType = 
"org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial")
+            
https://pdfbox.apache.org/docs/2.0.13/javadocs/org/apache/pdfbox/pdmodel/encryption/DecryptionMaterial.html[DecryptionMaterial].""";,
+              javaType = 
"org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial",
+              deprecationNote = "No longer read by the component since Camel 
2.21: PDFBox 2 decrypts at load time"
+                                + " via Loader.loadPDF(bytes, password). The 
byte[] converter loads without a password."
+                                + " Decrypt in a Processor before the PDF 
endpoint instead.")
+    @Deprecated
     public static final String DECRYPTION_MATERIAL_HEADER_NAME = 
"CamelPdfDecryptionMaterial";
 
     @Metadata(description = """
diff --git 
a/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfAppendTest.java
 
b/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfAppendTest.java
index d5f0b76d1783..d1347fc078f0 100644
--- 
a/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfAppendTest.java
+++ 
b/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfAppendTest.java
@@ -33,7 +33,6 @@ import org.apache.pdfbox.Loader;
 import org.apache.pdfbox.io.RandomAccessReadBuffer;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
-import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
 import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
 import org.apache.pdfbox.text.PDFTextStripper;
 import org.junit.jupiter.api.Test;
@@ -104,7 +103,6 @@ public class PdfAppendTest extends CamelTestSupport {
 
         Map<String, Object> headers = new HashMap<>();
         headers.put(PdfHeaderConstants.PDF_DOCUMENT_HEADER_NAME, 
encryptedDocument);
-        headers.put(PdfHeaderConstants.DECRYPTION_MATERIAL_HEADER_NAME, new 
StandardDecryptionMaterial(userPass));
 
         resultEndpoint.setExpectedMessageCount(1);
         resultEndpoint.expectedMessagesMatches(new Predicate() {
diff --git 
a/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfTextExtractionTest.java
 
b/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfTextExtractionTest.java
index 040bc75aabf6..7daaa99278a8 100644
--- 
a/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfTextExtractionTest.java
+++ 
b/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfTextExtractionTest.java
@@ -29,7 +29,6 @@ import org.apache.camel.test.junit6.CamelTestSupport;
 import org.apache.pdfbox.Loader;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
-import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
 import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
@@ -79,10 +78,7 @@ public class PdfTextExtractionTest extends CamelTestSupport {
         PDDocument encryptedDocument = Loader.loadPDF(output.toByteArray(), 
userPass);
 
         expectText();
-        template.sendBodyAndHeader("direct:start",
-                encryptedDocument,
-                PdfHeaderConstants.DECRYPTION_MATERIAL_HEADER_NAME,
-                new StandardDecryptionMaterial(userPass));
+        template.sendBody("direct:start", encryptedDocument);
         resultEndpoint.assertIsSatisfied();
     }
 
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 56b8b0d0ef7d..a3f16ba660e6 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -9728,6 +9728,27 @@ dropped from the consumer header tables of the 
`hazelcast-map` and `hazelcast-re
 their consumer sets it. Nothing replaces it: the cache the event came from is 
named by `CamelHazelcastCacheName`, and a
 route that needs to know which kind of cache that is can take it from the 
endpoint it consumes from.
 
+=== camel-pdf - the CamelPdfDecryptionMaterial header is deprecated
+
+The `CamelPdfDecryptionMaterial` header has had no effect since Camel 2.21. 
PDFBox 2 decrypts a document when it is
+loaded, from the password argument of `Loader.loadPDF`, so the producer was 
changed to stop calling the removed
+`PDDocument.openProtection(DecryptionMaterial)` and has not read the header 
since. A route that sets it gets no error
+and no decryption.
+
+It is now deprecated, with a `deprecationNote` that says so. Remove the header 
and load the document with its password
+before it reaches the endpoint, in a `Processor`:
+
+[source,java]
+----
+from("direct:start")
+    .process(e -> e.getMessage().setBody(
+            Loader.loadPDF(e.getMessage().getBody(byte[].class), "secret")))
+    .to("pdf:extractText");
+----
+
+The `byte[]` type converter of the component loads without a password, so an 
encrypted PDF sent as bytes still has to be
+loaded this way.
+
 === camel-whatsapp - both documented headers are deprecated
 
 `CamelWhatsAppPhoneNumberId` and `CamelWhatsAppRecipientPhoneNumberId` were 
the only two headers the component
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PdfEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PdfEndpointBuilderFactory.java
index e497c3c563c7..38643299881c 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PdfEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PdfEndpointBuilderFactory.java
@@ -431,7 +431,7 @@ public interface PdfEndpointBuilderFactory {
         }
         /**
          * Expected type is
-         * 
https://pdfbox.apache.org/docs/2.0.13/javadocs/org/apache/pdfbox/pdmodel/encryption/DecryptionMaterial.html[DecryptionMaterial].
 Mandatory* header if PDF document is encrypted.
+         * 
https://pdfbox.apache.org/docs/2.0.13/javadocs/org/apache/pdfbox/pdmodel/encryption/DecryptionMaterial.html[DecryptionMaterial].
 Deprecation note: No longer read by the component since Camel 2.21: PDFBox 2 
decrypts at load time via Loader.loadPDF(bytes, password). The byte[] converter 
loads without a password. Decrypt in a Processor before the PDF endpoint 
instead.
          * 
          * The option is a: {@code
          * org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial} type.
@@ -440,6 +440,7 @@ public interface PdfEndpointBuilderFactory {
          * 
          * @return the name of the header {@code PdfDecryptionMaterial}.
          */
+        @Deprecated
         public String pdfDecryptionMaterial() {
             return "CamelPdfDecryptionMaterial";
         }

Reply via email to