Class: HexaPDF::Encryption::StandardSecurityHandler::EncryptionOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/hexapdf/encryption/standard_security_handler.rb

Overview

Defines all possible options that can be passed to a StandardSecurityHandler when setting up encryption.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ EncryptionOptions

:nodoc:



197
198
199
200
201
202
203
204
205
206
207
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 197

def initialize(data = {})
  fallback_pwd = data.delete(:password) { '' }
  @user_password = data.delete(:user_password) { fallback_pwd }
  @owner_password = data.delete(:owner_password) { fallback_pwd }
  @permissions = process_permissions(data.delete(:permissions) { Permissions::ALL })
  @algorithm = data.delete(:algorithm) { :arc4 }
  @encrypt_metadata = data.delete(:encrypt_metadata) { true }
  if data.size > 0
    raise ArgumentError, "Invalid encryption options: #{data.keys.join(', ')}"
  end
end

Instance Attribute Details

#algorithmObject

The encryption algorithm.



191
192
193
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 191

def algorithm
  @algorithm
end

#encrypt_metadataObject

Specifies whether metadata should be encrypted.



194
195
196
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 194

def 
  @encrypt_metadata
end

#owner_passwordObject

The owner password. If this attribute is not specified but the virtual password attribute is, then the latter is used.



182
183
184
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 182

def owner_password
  @owner_password
end

#permissionsObject

The permissions. Either an integer with the needed permission bits set or an array of permission symbols.

See: Permissions



188
189
190
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 188

def permissions
  @permissions
end

#user_passwordObject

The user password. If this attribute is not specified but the virtual password attribute is, then the latter is used.



178
179
180
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 178

def user_password
  @user_password
end