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 Details

    • 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 Details

    • authenticatePassword

      public boolean authenticatePassword(String password)
      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:
      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.