Class: OpsWalrus::Cipher

Inherits:
Object
  • Object
show all
Defined in:
lib/opswalrus/hosts_file.rb

Direct Known Subclasses

AgeEncryptionCipher

Instance Method Summary collapse

Constructor Details

#initialize(id_to_public_key_map) ⇒ Cipher

id_to_public_key_map is a Hash of id-name/(PublicKey | Array String ) pairs



229
230
231
# File 'lib/opswalrus/hosts_file.rb', line 229

def initialize(id_to_public_key_map)
  @ids = id_to_public_key_map
end

Instance Method Details

#decrypt(value) ⇒ Object

returns the decrypted text as a String



261
262
263
# File 'lib/opswalrus/hosts_file.rb', line 261

def decrypt(value)
  raise "Not implemented"
end

#dereference(audience_id_reference) ⇒ Object

returns: PublicKey | nil | Array PublicKey



234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/opswalrus/hosts_file.rb', line 234

def dereference(audience_id_reference)
  case ref = @ids[audience_id_reference]
  when PublicKey
    ref
  when Array
    ref.map {|audience_id_reference| dereference(audience_id_reference) }.flatten.compact.uniq
  when Nil
    App.instance.warn "ID #{audience_id_reference} does not appear in the list of known public key identifiers"
    nil
  else
    raise "ID reference #{audience_id_reference} corresponds to an unknown type of public key or transitive ID reference: #{ref.inspect}"
  end
end

#dereference_all(audience_id_references) ⇒ Object

returns: Array PublicKey



249
250
251
# File 'lib/opswalrus/hosts_file.rb', line 249

def dereference_all(audience_id_references)
  audience_id_references.map {|audience_id_reference| dereference(audience_id_reference) }.flatten.compact.uniq
end

#encrypt(value, audience_id_references) ⇒ Object

value is the string value to be encrypted audience_id_references is an Array(String) representing the names associated with public keys in the ids section of the file returns the encrypted text as a String



256
257
258
# File 'lib/opswalrus/hosts_file.rb', line 256

def encrypt(value, audience_id_references)
  raise "Not implemented"
end

#encrypted?(value) ⇒ Boolean

Returns:

  • (Boolean)


265
266
267
# File 'lib/opswalrus/hosts_file.rb', line 265

def encrypted?(value)
  raise "Not implemented"
end