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:



208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 208

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 }
   = 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.



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

def algorithm
  @algorithm
end

#encrypt_metadataObject

Specifies whether metadata should be encrypted.



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

def 
  
end

#owner_passwordObject

The owner 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 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



199
200
201
# File 'lib/hexapdf/encryption/standard_security_handler.rb', line 199

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.



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

def user_password
  @user_password
end