From 68a0f7eca3bcd1c5b78febc1096c6dae97c228c3 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 17 Nov 2017 13:32:49 +0630 Subject: [PATCH] license sym config --- app/models/license.rb | 107 +++++------------------------------------- 1 file changed, 12 insertions(+), 95 deletions(-) diff --git a/app/models/license.rb b/app/models/license.rb index 32f1b48a..c4b9cdd2 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -21,15 +21,7 @@ class License # @secret = ENV["aes_key"] # @params = { query: { device: "SX", token: SECRETS_CONFIG['provision_key'] } } - end - - # def shop_code - # if ( self.subdomain.length > 3) - # return self.subdomain[0,3].upcase - # else - # return self.subdomain.upcase - # end - # end + end def detail_with_local_cache(lookup, key, iv) ##Check from local redis - if available load local otherwise get from remote @@ -87,61 +79,7 @@ class License if has_license puts "VERIFIED" end - end - - # if cache_license.nil? - # ##change the d/e 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 - - # if (@license["status"] == true) - - # assign() - - # Rails.logger.info "License - " + response.parsed_response.to_s - - # Redis.current do |conn| - # ##Remote - store the remote response in local redis cache - # conn.set(cache_key, Marshal.dump(@license)) - # ##ADD to List to remove later - # conn.sadd("License:cache:keys", cache_key) - # end - - # return true - # end - - # Rails.logger.info 'API License' - - # else - # @license = Marshal.load(cache_license) if cache_license - - # Rails.logger.info 'Cache License' - - # if (@license["status"] == true) - # assign() - # return true - # end - # end - # return false - #end - - # def detail - # response = self.class.get("/subdomain", @options) - # @license = response.parsed_response - - # Rails.logger.debug "License - " + response.parsed_response.to_s - - - # if (@license["status"] == true) - # assign() - - # return true - # end - - # return false - # end + end # License Activation def license_activate (key, iv, license_key, db_host, db_schema, db_user, db_password) @@ -154,8 +92,11 @@ class License if (@activate["status"]) response = create_license_file(@activate) if(response["status"]) - sym_path = "/home/yan/symmetric/engines" + sym_path = "/home/yan/symmetric/" response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password) + if(response["status"]) + run_symmetric(sym_path) + end end else response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"} @@ -180,35 +121,6 @@ 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) - - # @license = response.parsed_response - - # Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s - # if (@license["status"]) - # assign() - # end - # return @license["status"] - # 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) - - # @license = response.parsed_response - - # Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s - # if (@license["status"]) - # assign() - # 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) @@ -276,7 +188,7 @@ class License if File.directory? (sym_location) begin # sx properties create - f = File.open(sym_location + "/sx.properties", "w") + f = File.open(sym_location + "engines/sx.properties", "w") f.write("engine.name=sx\n") f.write("db.driver=com.mysql.jdbc.Driver\n") f.write("db.url=jdbc:mysql://#{db_host}/#{db_schema}?tinyInt1isBit=false\n") @@ -324,6 +236,11 @@ class License end end + # Run Symmetric + def run_symmetric(sym_path) + check_sym_proc = system(sym_path) + end + # Delete License File def delete_license_file File.delete("config/license.yml") if File.exist?("config/license.yml")