Class: Shhh::App::PrivateKey::Handler

Inherits:
Object
  • Object
show all
Includes:
Shhh
Defined in:
lib/shhh/app/private_key/handler.rb

Overview

This class figures out what is the private key that is provided to be used.

Constant Summary

Constants included from Shhh

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts, input_handler) ⇒ Handler

Returns a new instance of Handler


16
17
18
19
# File 'lib/shhh/app/private_key/handler.rb', line 16

def initialize(opts, input_handler)
  self.opts          = opts
  self.input_handler = input_handler
end

Instance Attribute Details

#input_handlerObject

Returns the value of attribute input_handler


13
14
15
# File 'lib/shhh/app/private_key/handler.rb', line 13

def input_handler
  @input_handler
end

#keyString

Returns key Private key detected

Returns:

  • (String)

    key Private key detected


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/shhh/app/private_key/handler.rb', line 23

def key
  return @key if @key

  @key = begin
    Detector.new(opts, input_handler).key
  rescue Shhh::Errors::Error => e
    if Shhh::App::Args.new(opts).key? && key.nil?
      raise e
    end
  end

  if @key && @key.length > 45
    @key = Decryptor.new(Base64Decoder.new(key).key, input_handler).key
  end

  @key
end

#optsObject

Returns the value of attribute opts


13
14
15
# File 'lib/shhh/app/private_key/handler.rb', line 13

def opts
  @opts
end