Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proguard rules. #406

Merged
merged 2 commits into from May 21, 2022
Merged

Add proguard rules. #406

merged 2 commits into from May 21, 2022

Conversation

tiper
Copy link
Contributor

@tiper tiper commented May 20, 2022

PdfBox-Android does reflection to instantiate SecurityHandlers.

@TomRoush TomRoush added the type: enhancement Request to add/improve a feature label May 20, 2022
@TomRoush TomRoush added this to the v2.0.22.0 milestone May 20, 2022
@TomRoush TomRoush self-assigned this May 20, 2022
@TomRoush
Copy link
Owner

This looks pretty good, thank you for contributing. I did have a few questions:

  • Can the rules file be moved to library/consumer-proguard-rules.txt? The Proguard file doesn't need to go in META-INF for an AAR library
  • We will also need to add consumerProguardFiles 'consumer-proguard-rules.txt' to library/build.gradle
  • What issue were you having before this change was made?

Set consumerProguardFiles property to add the proguard rules to the library project.
@tiper
Copy link
Contributor Author

tiper commented May 21, 2022

Hi @TomRoush.

  • Can the rules file be moved to library/consumer-proguard-rules.txt? The Proguard file doesn't need to go in META-INF for an AAR library.

  • We will also need to add consumerProguardFiles 'consumer-proguard-rules.txt' to library/build.gradle

✅✅

  • What issue were you having before this change was made?

Here's a stack trace when replicating the issue. Should be better than any explanation 😛

java.io.IOException: Error (RuntimeException) while creating security handler for decryption
    at com.tom_roush.pdfbox.pdfparser.COSParser.void prepareDecryption()(Unknown Source:2922)
    at com.tom_roush.pdfbox.pdfparser.COSParser.com.tom_roush.pdfbox.cos.COSDictionary retrieveTrailer()(Unknown Source:285)
    at com.tom_roush.pdfbox.pdfparser.PDFParser.void initialParse()(Unknown Source:169)
    at com.tom_roush.pdfbox.pdfparser.PDFParser.void parse()(Unknown Source:222)
    at com.tom_roush.pdfbox.pdmodel.PDDocument.com.tom_roush.pdfbox.pdmodel.PDDocument load(com.tom_roush.pdfbox.io.RandomAccessBufferedFileInputStream,java.lang.String,java.io.InputStream,java.lang.String,com.tom_roush.pdfbox.io.MemoryUsageSetting)(Unknown Source:1086)
    at com.tom_roush.pdfbox.pdmodel.PDDocument.com.tom_roush.pdfbox.pdmodel.PDDocument load(java.io.File,java.lang.String,java.io.InputStream,java.lang.String,com.tom_roush.pdfbox.io.MemoryUsageSetting)(Unknown Source:1069)
    at com.tom_roush.pdfbox.pdmodel.PDDocument.com.tom_roush.pdfbox.pdmodel.PDDocument load(java.io.File,com.tom_roush.pdfbox.io.MemoryUsageSetting)(Unknown Source:993)
    ...
 Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: com.tom_roush.pdfbox.pdmodel.encryption.StandardSecurityHandler.<init> []
    at com.tom_roush.pdfbox.pdmodel.encryption.SecurityHandlerFactory.com.tom_roush.pdfbox.pdmodel.encryption.SecurityHandler newSecurityHandler(java.lang.Class,java.lang.Class[],java.lang.Object[])(Unknown Source:137)
    at com.tom_roush.pdfbox.pdmodel.encryption.SecurityHandlerFactory.com.tom_roush.pdfbox.pdmodel.encryption.SecurityHandler newSecurityHandlerForFilter(java.lang.String)(Unknown Source:115)
    at com.tom_roush.pdfbox.pdmodel.encryption.PDEncryption.void <init>(com.tom_roush.pdfbox.cos.COSDictionary)(Unknown Source:97)
    at com.tom_roush.pdfbox.pdfparser.COSParser.void prepareDecryption()(Unknown Source:2898)
    ...
 Caused by: java.lang.NoSuchMethodException: com.tom_roush.pdfbox.pdmodel.encryption.StandardSecurityHandler.<init> []
    at java.lang.Class.getConstructor0(Class.java:2363)
    at java.lang.Class.getDeclaredConstructor(Class.java:2201)
    at com.tom_roush.pdfbox.pdmodel.encryption.SecurityHandlerFactory.com.tom_roush.pdfbox.pdmodel.encryption.SecurityHandler newSecurityHandler(java.lang.Class,java.lang.Class[],java.lang.Object[])(Unknown Source:131)
    ...

I've updated the PR. Let me know if there's anything else that needs to be done.

@TomRoush TomRoush merged commit a54ef00 into TomRoush:master May 21, 2022
@tiper tiper deleted the proguard branch May 22, 2022 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Request to add/improve a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants