lib/rhoconnect/license.rb in rhoconnect-3.4.5 vs lib/rhoconnect/license.rb in rhoconnect-4.0.0.beta.10
- old
+ new
@@ -1,14 +1,15 @@
require 'openssl'
+require 'pathname'
module Rhoconnect
class LicenseException < RuntimeError; end
class LicenseSeatsExceededException < LicenseException; end
class License
attr_reader :rhoconnect_version, :licensee, :seats, :issued
- #attr_accessor :license
+ attr_accessor :license
# ships with rhoconnect
RHO_PUBLICKEY = "99068e3a2708e6fe918252be8880eac539a1d2b2402651d75de5c7a2333a1cb2"
CLIENT_DOCKEY = 'rho_client_count'
@@ -17,11 +18,18 @@
if ENV['RHOCONNECT_LICENSE']
@license = ENV['RHOCONNECT_LICENSE']
elsif ENV['RHOSYNC_LICENSE']
@license = ENV['RHOSYNC_LICENSE']
else
+ app_config = Rhoconnect.get_config(Rhoconnect.base_directory)
settings = Rhoconnect.get_config(Rhoconnect.base_directory)[Rhoconnect.environment]
- @license = IO.read(File.join(Rhoconnect.base_directory,settings[:licensefile])).strip
+ licensefile = settings[:licensefile]
+ if licensefile
+ path_to_license = (Pathname.new(licensefile).absolute?) ? licensefile : File.join(Rhoconnect.base_directory, licensefile)
+ else
+ path_to_license = File.join(File.dirname(__FILE__), '..', '..', 'generators', 'templates', 'application', 'settings', 'license.key')
+ end
+ @license = IO.read(path_to_license).strip
end
_decrypt
rescue Exception => e
log e.message
log e.backtrace.join("\n")