Using PdfBox 2.0.3 from maven repository.
I modified a PDF with Adobe Pro to add editable fields that I can edit with PdfBox in JAVA.
Everything works well but I wanted to set the document as read-only so people downloading the generated pdf could not change values.
So I followed https://pdfbox.apache.org/2.0/cookbook/encryption.html but it's not working.
Here is my method https://gist.github.com/mgohin/b09fed91e7475c09326d1ae25686dcd1