Class: Sym::App::PrivateKey::Handler

Inherits:
Object
  • Object
show all
Includes:
Sym
Defined in:
lib/sym/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 Sym

BASH_COMPLETION, COMPLETION_FILE, COMPLETION_PATH, DESCRIPTION, ENV_ARGS_VARIABLE_NAME, LOGGER, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts, input_handler, password_cache) ⇒ Handler

Returns a new instance of Handler.



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

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

Instance Attribute Details

#input_handlerObject

Returns the value of attribute input_handler.



13
14
15
# File 'lib/sym/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



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

def key
  return @key if @key

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

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

  @key
end

#optsObject

Returns the value of attribute opts.



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

def opts
  @opts
end

#password_cacheObject

Returns the value of attribute password_cache.



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

def password_cache
  @password_cache
end