Package org.verapdf.pd.encryption
Class StandardSecurityHandler
- java.lang.Object
-
- org.verapdf.pd.encryption.StandardSecurityHandler
-
public class StandardSecurityHandler extends Object
Class represents standard security handler. It authenticates user password and calculates encryption key for document.- Author:
- Sergey Shemyakov
-
-
Constructor Summary
Constructors Constructor Description StandardSecurityHandler(PDEncryption pdEncryption, COSObject id, COSDocument document)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Boolean
authenticateEmptyPassword()
Checks if empty string is a user password to this PDF document and sets encryption key if password is successfully checked.void
decryptStream(COSStream stream, COSKey key)
Applies decryption filter to the stream so it can be read as unencrypted.void
decryptString(COSString string, COSKey stringKey)
Decrypts string and writes result into string.byte[]
getEncryptionKey()
PDEncryption
getPdEncryption()
boolean
isEmptyStringPassword()
-
-
-
Constructor Detail
-
StandardSecurityHandler
public StandardSecurityHandler(PDEncryption pdEncryption, COSObject id, COSDocument document)
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 Detail
-
authenticateEmptyPassword
public Boolean authenticateEmptyPassword()
Checks if empty string is a user password to this PDF document and sets encryption key if password is successfully checked.- Returns:
- true if empty string is a password to this PDF document.
-
getEncryptionKey
public byte[] getEncryptionKey()
- Returns:
- encryption key for this security handler. If empty string is not a valid password returns null.
-
isEmptyStringPassword
public boolean isEmptyStringPassword()
- Returns:
- true if empty string 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:
IOException
GeneralSecurityException
-
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:
IOException
GeneralSecurityException
-
getPdEncryption
public PDEncryption getPdEncryption()
- Returns:
- PDEncryption of this security handler.
-
-