From 7db4ace7b64aad04bcd06a3182731f7f2f100997 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 1 Dec 2017 14:15:06 +0630 Subject: [PATCH 1/4] license --- app/models/license.rb | 5 +++-- config/license.yml | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/models/license.rb b/app/models/license.rb index 2e9d729a..ffc19d06 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -145,6 +145,7 @@ class License end end end + return decrypted_line end private @@ -203,7 +204,7 @@ class License f.write("initial.load.create.first=true\n") f.write("initial.load.use.extract.job.enabled=true\n") f.close - +byebug # read from license file shop_name = read_license("shop_name") dbhost = read_license("dbhost") @@ -246,7 +247,7 @@ class License # if sym_install_status[1] == "false" # response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"} # end - +byebug # Run Sym Service sym_run_status = check_sym_running(check_sym_proc_str, sym_path) if sym_run_status diff --git a/config/license.yml b/config/license.yml index ad6521d6..c577c480 100644 --- a/config/license.yml +++ b/config/license.yml @@ -1,12 +1,12 @@ -iv_key: jR+ot8Fuq7KJiqdkV9FHBA== -shop_name: fkVo+T/vrp8n0g6YN0mE2w== +iv_key: E0/gk/s6POeZtUae1QGo8g== +shop_name: R6s4J457+8FD1pycH5vl9g== 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: A5OOsy/OEnIoMiqHNgrl8A== +dbschema: YfkMWJWhzPwt8GDFukk3dA== +dbusername: wcWA1CIUTq5NNIqmdAW79A== +dbpassword: I6t1lEqagOTQe1u87YPJJA== api_token: nGyMizHtoVEFYCjSVEFJuzkxuBJwSsH app_token: QUdPwSakcsnuVLdfkXgGHhPMiIOcSSfaVwQyA From 4b7cced87c2a042a63b3cf9fef2da19d4bef02b6 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 1 Dec 2017 15:19:24 +0630 Subject: [PATCH 2/4] license acti --- app/models/license.rb | 19 +++++++++++-------- config/license.yml | 12 ++++++------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/models/license.rb b/app/models/license.rb index ffc19d06..bece2adb 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -204,7 +204,7 @@ class License f.write("initial.load.create.first=true\n") f.write("initial.load.use.extract.job.enabled=true\n") f.close -byebug + # read from license file shop_name = read_license("shop_name") dbhost = read_license("dbhost") @@ -213,7 +213,7 @@ byebug 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") @@ -247,7 +247,7 @@ byebug # if sym_install_status[1] == "false" # response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"} # end -byebug + # Run Sym Service sym_run_status = check_sym_running(check_sym_proc_str, sym_path) if sym_run_status @@ -255,19 +255,22 @@ byebug 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 diff --git a/config/license.yml b/config/license.yml index c577c480..52e6160c 100644 --- a/config/license.yml +++ b/config/license.yml @@ -1,12 +1,12 @@ -iv_key: E0/gk/s6POeZtUae1QGo8g== -shop_name: R6s4J457+8FD1pycH5vl9g== +iv_key: bcXKbfOW+r64ibYXA4fU6g== +shop_name: Riz05xEt2Pc/tvyGjcnTnw== email: yanaung.nyein@code2lab.com telephone: 111111 fax: 111111 address: bitp -dbhost: A5OOsy/OEnIoMiqHNgrl8A== -dbschema: YfkMWJWhzPwt8GDFukk3dA== -dbusername: wcWA1CIUTq5NNIqmdAW79A== -dbpassword: I6t1lEqagOTQe1u87YPJJA== +dbhost: SMRuRTn59zAHEEdafri+Dg== +dbschema: iV7J64u6z9rqg5OFhf3OSw== +dbusername: gPg1PsWxrLNr/JXsmAch0A== +dbpassword: Xdq1p/jiewvgdG6LBAtRpw== api_token: nGyMizHtoVEFYCjSVEFJuzkxuBJwSsH app_token: QUdPwSakcsnuVLdfkXgGHhPMiIOcSSfaVwQyA From a50b49d2ace7e0fcbcf11c8b5fc8d8e4fb71515d Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 1 Dec 2017 16:24:51 +0630 Subject: [PATCH 3/4] license activate --- config/license.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/license.yml b/config/license.yml index 52e6160c..eab8f32e 100644 --- a/config/license.yml +++ b/config/license.yml @@ -1,12 +1,12 @@ -iv_key: bcXKbfOW+r64ibYXA4fU6g== -shop_name: Riz05xEt2Pc/tvyGjcnTnw== +iv_key: agEa1OwWkfL1+PCpyc5L2w== +shop_name: Su7XJ/AcJsTuOc9e7LzYJQ== email: yanaung.nyein@code2lab.com telephone: 111111 fax: 111111 address: bitp -dbhost: SMRuRTn59zAHEEdafri+Dg== -dbschema: iV7J64u6z9rqg5OFhf3OSw== -dbusername: gPg1PsWxrLNr/JXsmAch0A== -dbpassword: Xdq1p/jiewvgdG6LBAtRpw== +dbhost: ZUvBchuta4JY25yjJPGLYA== +dbschema: hNFEe1KXQ+CZqGuQ+c6v0w== +dbusername: pNJSbFV5EFOI6pOnVC84eA== +dbpassword: ON655p46MfQvkqVMYOXzBA== api_token: nGyMizHtoVEFYCjSVEFJuzkxuBJwSsH app_token: QUdPwSakcsnuVLdfkXgGHhPMiIOcSSfaVwQyA From 4548813bfd84ed32bb2d09690e8ae2b3ff13876c Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 1 Dec 2017 17:35:56 +0630 Subject: [PATCH 4/4] license verify --- app/controllers/application_controller.rb | 2 +- app/models/license.rb | 28 ++++++++++++++++++----- config/license.yml | 12 +++++----- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 258e24fb..3b7539a8 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/models/license.rb b/app/models/license.rb index bece2adb..359e58bc 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -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 @@ -148,6 +150,20 @@ class License 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 def decode_str(str) diff --git a/config/license.yml b/config/license.yml index eab8f32e..a7e53580 100644 --- a/config/license.yml +++ b/config/license.yml @@ -1,12 +1,12 @@ -iv_key: agEa1OwWkfL1+PCpyc5L2w== -shop_name: Su7XJ/AcJsTuOc9e7LzYJQ== +iv_key: A30HZdW+iDZA0vM5PAqwgg== +shop_name: 7DdPBxVo8m1xpa5T2kIcWQ== email: yanaung.nyein@code2lab.com telephone: 111111 fax: 111111 address: bitp -dbhost: ZUvBchuta4JY25yjJPGLYA== -dbschema: hNFEe1KXQ+CZqGuQ+c6v0w== -dbusername: pNJSbFV5EFOI6pOnVC84eA== -dbpassword: ON655p46MfQvkqVMYOXzBA== +dbhost: 9+83FZetcbLZi6COG5PbSw== +dbschema: shztSYIsNmM9nlHkR/4exQ== +dbusername: LapN+Geriht8yk866FxNiQ== +dbpassword: QtboWZ4ATE05vvYw6J+Uqw== api_token: nGyMizHtoVEFYCjSVEFJuzkxuBJwSsH app_token: QUdPwSakcsnuVLdfkXgGHhPMiIOcSSfaVwQyA