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.



56
57
58
59
# File 'lib/safenet.rb', line 56

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

Instance Method Details

#get_tokenObject



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

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



66
67
68
69
70
71
# File 'lib/safenet.rb', line 66

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