Merge branch 'license'

This commit is contained in:
Yan
2017-12-01 17:38:19 +06:30
3 changed files with 39 additions and 19 deletions

View File

@@ -58,7 +58,7 @@ class ApplicationController < ActionController::Base
def cache_license(url, lookup) def cache_license(url, lookup)
flag = ENV["AES_IV"] flag = ENV["AES_IV"]
@license = License.new(url, lookup) @license = License.new(url, lookup)
puts flag
# Check Exists IV # Check Exists IV
if flag == "<%= ENV['AES_IV'] %>" if flag == "<%= ENV['AES_IV'] %>"
# Export for Key # Export for Key

View File

@@ -74,10 +74,10 @@ class License
def detail_with_local_file() def detail_with_local_file()
has_license = true #verify_license() has_license = verify_license()
if has_license if has_license
# puts "VERIFIED" puts "VERIFIED"
end end
end end
@@ -104,8 +104,9 @@ class License
end end
def verify_license def verify_license
api_token = read_license("api_token") api_token = read_license_no_decrypt("api_token")
@params = { query: {lookup_type: "application", token: api_token} } puts api_token
@params = { query: {lookup_type: "application", api_token: api_token} }
response = self.class.get("/verify", @params) response = self.class.get("/verify", @params)
@varified = response.parsed_response @varified = response.parsed_response
@@ -121,7 +122,8 @@ class License
end end
# Check License expired date from PROVISION SERVER # Check License expired date from PROVISION SERVER
def check_expired(renewal_date) def check_expired(renewal_date_str)
renewal_date = DateTime.parse(renewal_date_str)
if (renewal_date < Date.today) if (renewal_date < Date.today)
return true return true
else else
@@ -145,6 +147,21 @@ class License
end end
end end
end end
return decrypted_line
end
# read line by key for license file without decrypt
def read_license_no_decrypt(key)
decrypted_line = ""
if File.exist?("config/license.yml")
File.open("config/license.yml").each do |line|
if line.include? (key)
decrypted_line_array = line.split(": ")
decrypted_line = decrypted_line_array[1]
end
end
end
return decrypted_line
end end
private private
@@ -212,7 +229,7 @@ class License
dbpassword = read_license("dbpassword") dbpassword = read_license("dbpassword")
# shop properties create # shop properties create
f = File.open(sym_location + "/#{shop_name}.properties", "w") f = File.open(sym_location + "engines/#{shop_name}.properties", "w")
f.write("engine.name=#{shop_name}\n") f.write("engine.name=#{shop_name}\n")
f.write("db.driver=com.mysql.jdbc.Driver\n") f.write("db.driver=com.mysql.jdbc.Driver\n")
f.write("db.url=jdbc:mysql://#{dbhost}/#{dbschema}?tinyInt1isBit=false\n") f.write("db.url=jdbc:mysql://#{dbhost}/#{dbschema}?tinyInt1isBit=false\n")
@@ -254,19 +271,22 @@ class License
check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables") check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables")
if check_sym_table if check_sym_table
sym_sql = Rails.root + "db/sym_master.sql" sym_sql = Rails.root + "db/sym_master.sql"
if File.exist? (sym_sql) if File.exist? (sym_sql)
# Import Sym Sql to db and start sym # Import Sym Sql to db and start sym
run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql) run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s)
run_sym = system(sym_path + "bin/sym") stop_sym = system("service SymmetricDS stop")
run_sym = system("service SymmetricDS start")
if run_sym if run_sym
response = { "status": true, "message": "Activation is success and Configuration done..."} response = { "status": true, "message": "Activation is success and Configuration done..."}
end end
else else
response = { "status": false, "message": "Activation is success but Symmetric Sql not Found. \n Please contact code2lab call center!"} response = { "status": false, "message": "Activation is success but Symmetric Sql not found. \n Please contact code2lab call center!"}
end end
end end
else
response = { "status": false, "message": "Activation is success but Symmetric not running. \n Please contact code2lab call center!"}
end end
end end
# Check Symmetric Running # Check Symmetric Running

View File

@@ -1,12 +1,12 @@
iv_key: jR+ot8Fuq7KJiqdkV9FHBA== iv_key: A30HZdW+iDZA0vM5PAqwgg==
shop_name: fkVo+T/vrp8n0g6YN0mE2w== shop_name: 7DdPBxVo8m1xpa5T2kIcWQ==
email: yanaung.nyein@code2lab.com email: yanaung.nyein@code2lab.com
telephone: 111111 telephone: 111111
fax: 111111 fax: 111111
address: bitp address: bitp
dbhost: zq3Nvh5W8jsB2cKjpKk/XQ== dbhost: 9+83FZetcbLZi6COG5PbSw==
dbschema: RkBK0CqEOqtfV9wCVNuoFA== dbschema: shztSYIsNmM9nlHkR/4exQ==
dbusername: CN++Xa5WobVgH/7/QKGTiQ== dbusername: LapN+Geriht8yk866FxNiQ==
dbpassword: mYJQZqe/XEtwB6ccOvUbdw== dbpassword: QtboWZ4ATE05vvYw6J+Uqw==
api_token: nGyMizHtoVEFYCjSVEFJuzkxuBJwSsH api_token: nGyMizHtoVEFYCjSVEFJuzkxuBJwSsH
app_token: QUdPwSakcsnuVLdfkXgGHhPMiIOcSSfaVwQyA app_token: QUdPwSakcsnuVLdfkXgGHhPMiIOcSSfaVwQyA