Class ProtectWorkbook
java.lang.Object
org.docx4j.openpackaging.packages.ProtectionSettings
org.docx4j.openpackaging.packages.ProtectWorkbook
public class ProtectWorkbook extends ProtectionSettings
- Since:
- 3.3.0
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Loggerlog -
Constructor Summary
Constructors Constructor Description ProtectWorkbook(SpreadsheetMLPackage pkg) -
Method Summary
Modifier and Type Method Description CTSheetProtectiongetSheetProtection(WorksheetPart worksheetPart)Use this method to get the CTSheetProtection object for the specified worksheet, so you can set its parameters as you see fit.voidremoveWorkbookProtection()Remove protection from this package.voidsetSheetProtection(CTSheetProtection sheetProtection, java.lang.String password, HashAlgorithm hashAlgo)Enforces the protection passed in sheetProtection, with the specified password, and HashAlgorithm for the password.voidsetSheetProtectionPassword(CTSheetProtection sheetProtection, java.lang.String password)Enforces the protection passed in sheetProtection, with the specified password, using sha512 (like Excel 2013).voidsetWorkbookProtection(java.lang.String password, boolean lockRevision, boolean lockStructure, boolean lockWindows)Enforce Workbook Protection, with the specified password, using sha512 (like Excel 2013).voidsetWorkbookProtection(java.lang.String password, HashAlgorithm hashAlgo, boolean lockRevision, boolean lockStructure, boolean lockWindows)Enforce Workbook Protection, with the specified password, using hashAlgo.static booleanvalidateSheetProtectionPassword(CTSheetProtection sheetProtection, java.lang.String password)Validates the password, i.e.booleanvalidateWorkbookProtectionPassword(java.lang.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
-
Method Details
-
removeWorkbookProtection
Remove protection from this package.- Throws:
Xlsx4jException
-
setWorkbookProtection
public void setWorkbookProtection(java.lang.String password, boolean lockRevision, boolean lockStructure, boolean lockWindows) throws Xlsx4jExceptionEnforce 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(java.lang.String password, HashAlgorithm hashAlgo, boolean lockRevision, boolean lockStructure, boolean lockWindows) throws Xlsx4jExceptionEnforce Workbook Protection, with the specified password, using hashAlgo.- Parameters:
password- if null, no password will be usedhashAlgo-lockRevision-lockStructure-lockWindows-- Throws:
Xlsx4jException
-
validateWorkbookProtectionPassword
public boolean validateWorkbookProtectionPassword(java.lang.String password) throws Xlsx4jExceptionCheck 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, java.lang.String password) throws Xlsx4jExceptionEnforces 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, java.lang.String password, HashAlgorithm hashAlgo) throws Xlsx4jExceptionEnforces 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, java.lang.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
-