adding license activation

This commit is contained in:
Yan
2017-11-15 17:55:51 +06:30
parent 50bf67f5e5
commit c2095b4a61
3 changed files with 55 additions and 37 deletions

View File

@@ -80,6 +80,7 @@ class License
if has_license
puts "VERIFIED"
end
end
# if cache_license.nil?
# ##change the d/e key
@@ -119,26 +120,31 @@ class License
# return false
end
def detail
response = self.class.get("/subdomain", @options)
@license = response.parsed_response
# def detail
# response = self.class.get("/subdomain", @options)
# @license = response.parsed_response
Rails.logger.debug "License - " + response.parsed_response.to_s
# Rails.logger.debug "License - " + response.parsed_response.to_s
if (@license["status"] == true)
assign()
# if (@license["status"] == true)
# assign()
return true
end
# return true
# end
# return false
# end
# License Activation
def license_activate
return false
end
def verify_license
api_token = read_license("api_token")
@options = { query: {lookup_type: "application", token: api_token} }
response = self.class.get("/verify", @options)
@params = { query: {lookup_type: "application", token: api_token} }
response = self.class.get("/verify", @params)
@varified = response.parsed_response
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
@@ -152,37 +158,36 @@ class License
return false
end
def check_remote_license(license_key)
# @options = { query: {device: "cloud", key: license_key, skey: @secret, token: Rails.application.secrets.provision_key} }
@options = { query: {lookup_type: "application", encrypted_key: @secret, token: SECRETS_CONFIG['provision_key']} }
response = self.class.get("/license", @options)
# def check_remote_license(license_key)
# # @options = { query: {device: "cloud", key: license_key, skey: @secret, token: Rails.application.secrets.provision_key} }
# @options = { query: {lookup_type: "application", encrypted_key: @secret, token: SECRETS_CONFIG['provision_key']} }
# response = self.class.get("/license", @options)
@license = response.parsed_response
# @license = response.parsed_response
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
if (@license["status"])
assign()
end
return @license["status"]
# Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
# if (@license["status"])
# assign()
# end
# return @license["status"]
# end
end
# def verify_by_api_token(api_token)
# @options = { query: {device: "SX", api_token: api_token, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
# response = self.class.get("/verify_token", @options)
def verify_by_api_token(api_token)
@options = { query: {device: "SX", api_token: api_token, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
response = self.class.get("/verify", @options)
# @license = response.parsed_response
@license = response.parsed_response
# Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
# if (@license["status"])
# assign()
# end
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
if (@license["status"])
assign()
end
return @license["status"]
end
# return @license["status"]
# end
#Load License is remove from the cloud license because - this license is must be validated against subdmain instead of license.data from file.
# Check License expired date from PROVISION SERVER
def check_expired(renewal_date)
if (renewal_date < Date.today)
return true
@@ -191,6 +196,7 @@ class License
end
end
# Check License File exists
def self.check_license_file
return File.exist?("config/license.yml")
end
@@ -209,6 +215,13 @@ class License
end
private
# Delete License File
def delete_license_file
File.delete("config/license.yml") if File.exist?("config/license.yml")
end
# Assign db info for Cloud
def assign
# self.name = @license["name"]
# self.address_1 = @license["address_1"]
@@ -228,7 +241,6 @@ class License
## self.plan_activation_date = Date.strptime(@license["plan_activation_date"], "%Y-%m-%d")
## self.plan_next_renewal_date = Date.strptime(@license["plan_next_renewal_date"], "%Y-%m-%d")
# self.plan_max_products = @license["plan_max_products"].to_i
# self.plan_max_customers = @license["plan_max_customers"].to_i
# self.plan_active_connections = @license["plan_active_connections"].to_i