adding license
This commit is contained in:
@@ -5,9 +5,14 @@ require 'uri'
|
||||
class AESEncDec {
|
||||
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
|
||||
|
||||
def self.export_key
|
||||
ENV['aes_key'] = cipher.key = cipher.random_key # stores the key in key, and also sets the generated key on the cipher
|
||||
def self.export_key(passphrase)
|
||||
# We want a 256 bit key symetric key based on passphrase
|
||||
digest = Digest::SHA256.new
|
||||
key = digest.update(passphrase)
|
||||
# key = digest.digest
|
||||
ENV['aes_key'] = cipher.key = key # stores the key in key, and also sets the generated key on the cipher
|
||||
ENV['aes_iv'] = cipher.iv = cipher.random_iv # stores the iv in iv, and also sets the generated iv on the cipher
|
||||
return cipher.key, cipher.iv
|
||||
end
|
||||
|
||||
def self.encrypt(data)
|
||||
|
||||
@@ -20,9 +20,9 @@ class License
|
||||
end
|
||||
|
||||
# generate key for license file encrypt
|
||||
AESEncDec.export_key()
|
||||
# AESEncDec.export_key()
|
||||
|
||||
@secret = ENV["aes_key"]
|
||||
# @secret = ENV["aes_key"]
|
||||
@params = { query: { device: "SX", token: SECRETS_CONFIG['provision_key'] } }
|
||||
end
|
||||
|
||||
@@ -32,32 +32,32 @@ class License
|
||||
else
|
||||
return self.subdomain.upcase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_license_file
|
||||
return File.exist?("config/license.yml")
|
||||
end
|
||||
|
||||
def detail_with_local_cache(lookup, key)
|
||||
def detail_with_local_file(lookup, key, iv)
|
||||
##Check from local redis - if available load local otherwise get from remote
|
||||
cache_key = "store:license:#{key}:hostname"
|
||||
#cache_key = "store:license:#{key}:hostname"
|
||||
|
||||
# No Needs for current
|
||||
# @secret = key
|
||||
|
||||
cache_license = nil
|
||||
#cache_license = nil
|
||||
|
||||
##Get redis connection from connection pool
|
||||
Redis.current do |conn|
|
||||
cache_license = conn.get(cache_key)
|
||||
end
|
||||
#
|
||||
|
||||
Rails.logger.info "Cache key - " + cache_key.to_s
|
||||
#Rails.logger.info "Cache key - " + cache_key.to_s
|
||||
|
||||
has_license = check_license_file
|
||||
|
||||
if has_license
|
||||
|
||||
end
|
||||
|
||||
if cache_license.nil?
|
||||
##change the d/e key
|
||||
# @options = { query: {device: "SXlite", lookup: lookup, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
|
||||
@params = { query: { lookup_type: "cloud", lookup: "subdomain", token: SECRETS_CONFIG['license_key']} }
|
||||
@params = { query: { lookup_type: self.server_mode, lookup: lookup, encrypted_key: key, iv_key: iv} }
|
||||
|
||||
response = self.class.get("/request_license", @params)
|
||||
@license = response.parsed_response
|
||||
@@ -95,7 +95,6 @@ class License
|
||||
end
|
||||
|
||||
def detail
|
||||
|
||||
response = self.class.get("/subdomain", @options)
|
||||
@license = response.parsed_response
|
||||
|
||||
@@ -151,6 +150,10 @@ class License
|
||||
end
|
||||
|
||||
private
|
||||
def check_license_file
|
||||
return File.exist?("config/license.yml")
|
||||
end
|
||||
|
||||
def assign
|
||||
# self.name = @license["name"]
|
||||
# self.address_1 = @license["address_1"]
|
||||
|
||||
Reference in New Issue
Block a user