Package org.verapdf.pd.encryption
Class StandardSecurityHandler
java.lang.Object
org.verapdf.pd.encryption.StandardSecurityHandler
Class represents standard security handler. It authenticates user password
and calculates encryption key for document.
- Author:
- Sergey Shemyakov
-
Constructor Summary
ConstructorsConstructorDescriptionStandardSecurityHandler(PDEncryption pdEncryption, COSObject id, COSDocument document) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanauthenticatePassword(String password) Checks if a given password is a user password to this PDF document and sets encryption key if password is successfully checked.booleanvoiddecryptStream(COSStream stream, COSKey key) Applies decryption filter to the stream so it can be read as unencrypted.voiddecryptString(COSString string, COSKey stringKey) Decrypts string and writes result into string.byte[]
-
Constructor Details
-
StandardSecurityHandler
Constructor.- Parameters:
pdEncryption- is encryption object of this PDF document.id- is ID object from document trailer.document- is COSDocument object associated with this security handler
-
-
Method Details
-
authenticatePassword
Checks if a given password is a user password to this PDF document and sets encryption key if password is successfully checked.- Returns:
- true if a given password is a password to this PDF document.
-
getEncryptionKey
public byte[] getEncryptionKey()- Returns:
- encryption key for this security handler. If password given by the user or empty string (if user's password is null) is not a valid password returns null.
-
checkPassword
public boolean checkPassword()- Returns:
- true if the password given by the user or an empty string (if user's password is null) is a valid password for this PDF document.
-
decryptString
public void decryptString(COSString string, COSKey stringKey) throws IOException, GeneralSecurityException Decrypts string and writes result into string.- Parameters:
string- is COSString to decrypt.stringKey- is COSKey of object that contains this COSString.- Throws:
IOExceptionGeneralSecurityException
-
decryptStream
public void decryptStream(COSStream stream, COSKey key) throws IOException, GeneralSecurityException Applies decryption filter to the stream so it can be read as unencrypted.- Parameters:
stream- is COSStream with encrypted data.key- is COSKey of this stream.- Throws:
IOExceptionGeneralSecurityException
-
getPdEncryption
- Returns:
- PDEncryption of this security handler.
-