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)
flag = ENV["AES_IV"]
@license = License.new(url, lookup)
puts flag
# Check Exists IV
if flag == "<%= ENV['AES_IV'] %>"
# Export for Key

View File

@@ -74,10 +74,10 @@ class License
def detail_with_local_file()
has_license = true #verify_license()
has_license = verify_license()
if has_license
# puts "VERIFIED"
puts "VERIFIED"
end
end
@@ -103,9 +103,10 @@ class License
return response
end
def verify_license
api_token = read_license("api_token")
@params = { query: {lookup_type: "application", token: api_token} }
def verify_license
api_token = read_license_no_decrypt("api_token")
puts api_token
@params = { query: {lookup_type: "application", api_token: api_token} }
response = self.class.get("/verify", @params)
@varified = response.parsed_response
@@ -121,7 +122,8 @@ class License
end
# 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)
return true
else
@@ -145,6 +147,21 @@ class License
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
private
@@ -212,7 +229,7 @@ class License
dbpassword = read_license("dbpassword")
# 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("db.driver=com.mysql.jdbc.Driver\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")
if check_sym_table
sym_sql = Rails.root + "db/sym_master.sql"
if File.exist? (sym_sql)
# Import Sym Sql to db and start sym
run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql)
run_sym = system(sym_path + "bin/sym")
run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s)
stop_sym = system("service SymmetricDS stop")
run_sym = system("service SymmetricDS start")
if run_sym
response = { "status": true, "message": "Activation is success and Configuration done..."}
end
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
else
response = { "status": false, "message": "Activation is success but Symmetric not running. \n Please contact code2lab call center!"}
end
end
# Check Symmetric Running

View File

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