Class: SafeNet::KeyHelper

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

Instance Method Summary collapse

Constructor Details

#initialize(client_obj) ⇒ KeyHelper

Returns a new instance of KeyHelper.



60
61
62
63
# File 'lib/safenet.rb', line 60

def initialize(client_obj)
  @client = client_obj
  @conf = {}
end

Instance Method Details

#get_tokenObject



65
66
67
68
# File 'lib/safenet.rb', line 65

def get_token
  @conf = File.exists?(@client.app_info[:conf_path]) ? JSON.parse(File.read(@client.app_info[:conf_path])) : (@client.auth.auth() || {})
  @conf["token"]
end

#get_valid_tokenObject



70
71
72
73
74
75
# File 'lib/safenet.rb', line 70

def get_valid_token
  @last_conf = File.exists?(@client.app_info[:conf_path]) ? JSON.parse(File.read(@client.app_info[:conf_path])) : {}
  @client.auth.auth() unless File.exists?(@client.app_info[:conf_path]) && @client.auth.is_token_valid()
  @conf = JSON.parse(File.read(@client.app_info[:conf_path]))
  @conf["token"]
end