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:



212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 212

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

Instance Attribute Details

#algorithmObject

The encryption algorithm.



206
207
208
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 206

def algorithm
  @algorithm
end

#encrypt_metadataObject

Specifies whether metadata should be encrypted.



209
210
211
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 209

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.



197
198
199
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 197

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



203
204
205
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 203

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.



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

def user_password
  @user_password
end