Class ProtectWorkbook
java.lang.Object
org.docx4j.openpackaging.packages.ProtectionSettings
org.docx4j.openpackaging.packages.ProtectWorkbook
- Since:
- 3.3.0
-
Field Summary
FieldsFields inherited from class org.docx4j.openpackaging.packages.ProtectionSettings
pkg -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetSheetProtection(WorksheetPart worksheetPart) Use this method to get the CTSheetProtection object for the specified worksheet, so you can set its parameters as you see fit.voidRemove protection from this package.voidsetSheetProtection(CTSheetProtection sheetProtection, String password, HashAlgorithm hashAlgo) Enforces the protection passed in sheetProtection, with the specified password, and HashAlgorithm for the password.voidsetSheetProtectionPassword(CTSheetProtection sheetProtection, String password) Enforces the protection passed in sheetProtection, with the specified password, using sha512 (like Excel 2013).voidsetWorkbookProtection(String password, boolean lockRevision, boolean lockStructure, boolean lockWindows) Enforce Workbook Protection, with the specified password, using sha512 (like Excel 2013).voidsetWorkbookProtection(String password, HashAlgorithm hashAlgo, boolean lockRevision, boolean lockStructure, boolean lockWindows) Enforce Workbook Protection, with the specified password, using hashAlgo.static booleanvalidateSheetProtectionPassword(CTSheetProtection sheetProtection, String password) Validates the password, i.e.booleanvalidateWorkbookProtectionPassword(String password) Check the password is correct?Methods inherited from class org.docx4j.openpackaging.packages.ProtectionSettings
getMarkAsFinal, getSignatureHelper, setDocSecurity, setMarkAsFinal
-
Field Details
-
log
protected static org.slf4j.Logger log
-
-
Constructor Details
-
ProtectWorkbook
-
-
Method Details
-
removeWorkbookProtection
Remove protection from this package.- Throws:
Xlsx4jException
-
setWorkbookProtection
public void setWorkbookProtection(String password, boolean lockRevision, boolean lockStructure, boolean lockWindows) throws Xlsx4jException Enforce Workbook Protection, with the specified password, using sha512 (like Excel 2013).- Parameters:
password- if null, no password will be usedlockRevision-lockStructure-lockWindows-- Throws:
Xlsx4jException
-
setWorkbookProtection
public void setWorkbookProtection(String password, HashAlgorithm hashAlgo, boolean lockRevision, boolean lockStructure, boolean lockWindows) throws Xlsx4jException Enforce Workbook Protection, with the specified password, using hashAlgo.- Parameters:
password- if null, no password will be usedhashAlgo-lockRevision-lockStructure-lockWindows-- Throws:
Xlsx4jException
-
validateWorkbookProtectionPassword
Check the password is correct?- Parameters:
password-- Returns:
- Throws:
Xlsx4jException
-
getSheetProtection
Use this method to get the CTSheetProtection object for the specified worksheet, so you can set its parameters as you see fit.- Parameters:
worksheetPart-- Returns:
- Throws:
Xlsx4jException
-
setSheetProtectionPassword
public void setSheetProtectionPassword(CTSheetProtection sheetProtection, String password) throws Xlsx4jException Enforces the protection passed in sheetProtection, with the specified password, using sha512 (like Excel 2013).- Parameters:
sheetProtection-password-- Throws:
Xlsx4jException- Since:
- 3.3.0
-
setSheetProtection
public void setSheetProtection(CTSheetProtection sheetProtection, String password, HashAlgorithm hashAlgo) throws Xlsx4jException Enforces the protection passed in sheetProtection, with the specified password, and HashAlgorithm for the password.- Parameters:
password- the plaintext password, if null no password will be appliedhashAlgo- the hash algorithm - only md2, m5, sha1, sha256, sha384 and sha512 are supported. if null, it will default default to sha512 (like Excel 2013) if none, it will behave like Excel 2010- Throws:
Xlsx4jException- Since:
- 3.3.0
-
validateSheetProtectionPassword
public static boolean validateSheetProtectionPassword(CTSheetProtection sheetProtection, String password) Validates the password, i.e. calculates the hash of the given password and compares it against the stored hash- Parameters:
sheetProtection-password- the password, if null the method will always return false, even if there's no password set- Returns:
- true, if the hashes match
- Since:
- 3.3.0
-