diff --git a/build.gradle b/build.gradle index 30d98373..755bb01c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'stirling.software' -version = '0.9.1' +version = '0.10.0' sourceCompatibility = '17' repositories { diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java index 585e41f3..e0fe97c7 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java @@ -50,8 +50,11 @@ public class PasswordController { @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file to which the password should be added", required = true) MultipartFile fileInput, + @RequestParam(defaultValue = "", name = "ownerPassword") + @Parameter(description = "The owner password to be added to the PDF file (Restricts what can be done with the document once it is opened)") + String ownerPassword, @RequestParam(defaultValue = "", name = "password") - @Parameter(description = "The password to be added to the PDF file") + @Parameter(description = "The password to be added to the PDF file (Restricts the opening of the document itself.)") String password, @RequestParam(defaultValue = "128", name = "keyLength") @Parameter(description = "The length of the encryption key", schema = @Schema(allowableValues = {"40", "128", "256"})) @@ -84,7 +87,6 @@ public class PasswordController { PDDocument document = PDDocument.load(fileInput.getBytes()); AccessPermission ap = new AccessPermission(); - ap.setCanAssembleDocument(!canAssembleDocument); ap.setCanExtractContent(!canExtractContent); ap.setCanExtractForAccessibility(!canExtractForAccessibility); @@ -93,7 +95,10 @@ public class PasswordController { ap.setCanModifyAnnotations(!canModifyAnnotations); ap.setCanPrint(!canPrint); ap.setCanPrintFaithful(!canPrintFaithful); - StandardProtectionPolicy spp = new StandardProtectionPolicy(password, password, ap); + StandardProtectionPolicy spp = new StandardProtectionPolicy(ownerPassword, password, ap); + + + spp.setEncryptionKeyLength(keyLength); spp.setPermissions(ap); diff --git a/src/main/resources/messages_en_GB.properties b/src/main/resources/messages_en_GB.properties index 02e5286d..85632661 100644 --- a/src/main/resources/messages_en_GB.properties +++ b/src/main/resources/messages_en_GB.properties @@ -342,10 +342,10 @@ pdfToImage.submit=Convert addPassword.title=Add Password addPassword.header=Add password (Encrypt) addPassword.selectText.1=Select PDF to encrypt -addPassword.selectText.2=Password +addPassword.selectText.2=User Password addPassword.selectText.3=Encryption Key Length addPassword.selectText.4=Higher values are stronger, but lower values have better compatibility. -addPassword.selectText.5=Permissions to set +addPassword.selectText.5=Permissions to set (Recommended to be used along with Owner password) addPassword.selectText.6=Prevent assembly of document addPassword.selectText.7=Prevent content extraction addPassword.selectText.8=Prevent extraction for accessibility @@ -354,6 +354,9 @@ addPassword.selectText.10=Prevent modification addPassword.selectText.11=Prevent annotation modification addPassword.selectText.12=Prevent printing addPassword.selectText.13=Prevent printing different formats +addPassword.selectText.14=Owner Password +addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers) +addPassword.selectText.16=Restricts the opening of the document itself addPassword.submit=Encrypt #watermark diff --git a/src/main/resources/templates/security/add-password.html b/src/main/resources/templates/security/add-password.html index 866b2903..52005eb0 100644 --- a/src/main/resources/templates/security/add-password.html +++ b/src/main/resources/templates/security/add-password.html @@ -19,8 +19,14 @@
- + +
+
+ + +
+