aspera-cli 4.5.0 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +1 -0
  3. data/README.md +1894 -1574
  4. data/bin/ascli +21 -1
  5. data/bin/asession +38 -34
  6. data/docs/test_env.conf +14 -3
  7. data/examples/aoc.rb +17 -15
  8. data/examples/dascli +26 -0
  9. data/examples/faspex4.rb +42 -35
  10. data/examples/proxy.pac +1 -1
  11. data/examples/transfer.rb +38 -37
  12. data/lib/aspera/aoc.rb +245 -205
  13. data/lib/aspera/ascmd.rb +111 -90
  14. data/lib/aspera/ats_api.rb +16 -14
  15. data/lib/aspera/cli/basic_auth_plugin.rb +19 -18
  16. data/lib/aspera/cli/extended_value.rb +50 -39
  17. data/lib/aspera/cli/formater.rb +161 -135
  18. data/lib/aspera/cli/info.rb +18 -0
  19. data/lib/aspera/cli/listener/line_dump.rb +4 -2
  20. data/lib/aspera/cli/listener/logger.rb +3 -1
  21. data/lib/aspera/cli/listener/progress.rb +20 -21
  22. data/lib/aspera/cli/listener/progress_multi.rb +29 -31
  23. data/lib/aspera/cli/main.rb +194 -183
  24. data/lib/aspera/cli/manager.rb +213 -206
  25. data/lib/aspera/cli/plugin.rb +71 -49
  26. data/lib/aspera/cli/plugins/alee.rb +8 -7
  27. data/lib/aspera/cli/plugins/aoc.rb +675 -558
  28. data/lib/aspera/cli/plugins/ats.rb +116 -109
  29. data/lib/aspera/cli/plugins/bss.rb +35 -34
  30. data/lib/aspera/cli/plugins/config.rb +722 -542
  31. data/lib/aspera/cli/plugins/console.rb +28 -22
  32. data/lib/aspera/cli/plugins/cos.rb +28 -37
  33. data/lib/aspera/cli/plugins/faspex.rb +281 -227
  34. data/lib/aspera/cli/plugins/faspex5.rb +129 -84
  35. data/lib/aspera/cli/plugins/node.rb +426 -232
  36. data/lib/aspera/cli/plugins/orchestrator.rb +106 -98
  37. data/lib/aspera/cli/plugins/preview.rb +196 -191
  38. data/lib/aspera/cli/plugins/server.rb +131 -126
  39. data/lib/aspera/cli/plugins/shares.rb +49 -36
  40. data/lib/aspera/cli/plugins/sync.rb +27 -28
  41. data/lib/aspera/cli/transfer_agent.rb +84 -79
  42. data/lib/aspera/cli/version.rb +3 -1
  43. data/lib/aspera/colors.rb +37 -28
  44. data/lib/aspera/command_line_builder.rb +84 -63
  45. data/lib/aspera/cos_node.rb +68 -34
  46. data/lib/aspera/data_repository.rb +4 -2
  47. data/lib/aspera/environment.rb +61 -46
  48. data/lib/aspera/fasp/agent_base.rb +36 -31
  49. data/lib/aspera/fasp/agent_connect.rb +44 -37
  50. data/lib/aspera/fasp/agent_direct.rb +101 -104
  51. data/lib/aspera/fasp/agent_httpgw.rb +91 -90
  52. data/lib/aspera/fasp/agent_node.rb +36 -33
  53. data/lib/aspera/fasp/agent_trsdk.rb +28 -31
  54. data/lib/aspera/fasp/error.rb +3 -1
  55. data/lib/aspera/fasp/error_info.rb +81 -54
  56. data/lib/aspera/fasp/installation.rb +171 -151
  57. data/lib/aspera/fasp/listener.rb +2 -0
  58. data/lib/aspera/fasp/parameters.rb +105 -111
  59. data/lib/aspera/fasp/parameters.yaml +305 -249
  60. data/lib/aspera/fasp/resume_policy.rb +20 -20
  61. data/lib/aspera/fasp/transfer_spec.rb +27 -0
  62. data/lib/aspera/fasp/uri.rb +31 -29
  63. data/lib/aspera/faspex_gw.rb +95 -118
  64. data/lib/aspera/hash_ext.rb +12 -13
  65. data/lib/aspera/id_generator.rb +11 -9
  66. data/lib/aspera/keychain/encrypted_hash.rb +73 -57
  67. data/lib/aspera/keychain/macos_security.rb +27 -29
  68. data/lib/aspera/log.rb +40 -39
  69. data/lib/aspera/nagios.rb +24 -22
  70. data/lib/aspera/node.rb +38 -30
  71. data/lib/aspera/oauth.rb +217 -248
  72. data/lib/aspera/open_application.rb +9 -7
  73. data/lib/aspera/persistency_action_once.rb +15 -14
  74. data/lib/aspera/persistency_folder.rb +15 -18
  75. data/lib/aspera/preview/file_types.rb +266 -270
  76. data/lib/aspera/preview/generator.rb +94 -92
  77. data/lib/aspera/preview/image_error.png +0 -0
  78. data/lib/aspera/preview/options.rb +20 -17
  79. data/lib/aspera/preview/utils.rb +99 -102
  80. data/lib/aspera/preview/video_error.png +0 -0
  81. data/lib/aspera/{proxy_auto_config.erb.js → proxy_auto_config.js} +23 -31
  82. data/lib/aspera/proxy_auto_config.rb +114 -21
  83. data/lib/aspera/rest.rb +144 -142
  84. data/lib/aspera/rest_call_error.rb +3 -2
  85. data/lib/aspera/rest_error_analyzer.rb +31 -31
  86. data/lib/aspera/rest_errors_aspera.rb +18 -16
  87. data/lib/aspera/secret_hider.rb +68 -0
  88. data/lib/aspera/ssh.rb +20 -16
  89. data/lib/aspera/sync.rb +57 -54
  90. data/lib/aspera/temp_file_manager.rb +20 -14
  91. data/lib/aspera/timer_limiter.rb +10 -8
  92. data/lib/aspera/uri_reader.rb +14 -15
  93. data/lib/aspera/web_auth.rb +85 -80
  94. data.tar.gz.sig +0 -0
  95. metadata +169 -40
  96. metadata.gz.sig +2 -0
  97. data/bin/dascli +0 -13
  98. data/docs/Makefile +0 -63
  99. data/docs/README.erb.md +0 -4221
  100. data/docs/README.md +0 -13
  101. data/docs/diagrams.txt +0 -49
  102. data/docs/doc_tools.rb +0 -58
  103. data/lib/aspera/cli/plugins/shares2.rb +0 -114
  104. data/lib/aspera/fasp/default.rb +0 -17
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
1
4
  require 'singleton'
2
5
  require 'aspera/log'
3
6
  require 'aspera/environment'
@@ -6,6 +9,7 @@ require 'xmlsimple'
6
9
  require 'zlib'
7
10
  require 'base64'
8
11
  require 'fileutils'
12
+ require 'openssl'
9
13
 
10
14
  module Aspera
11
15
  module Fasp
@@ -18,73 +22,101 @@ module Aspera
18
22
  # Installation.instance.ascp_path=""
19
23
  class Installation
20
24
  include Singleton
21
- PRODUCT_CONNECT='Aspera Connect'
22
- PRODUCT_CLI_V1='Aspera CLI'
23
- PRODUCT_DRIVE='Aspera Drive'
24
- PRODUCT_ENTSRV='Enterprise Server'
25
+ # known product names
26
+ PRODUCT_CONNECT = 'Aspera Connect'
27
+ PRODUCT_CLI_V1 = 'Aspera CLI'
28
+ PRODUCT_DRIVE = 'Aspera Drive'
29
+ PRODUCT_ENTSRV = 'Enterprise Server'
25
30
  # protobuf generated files from sdk
26
- EXT_RUBY_PROTOBUF='_pb.rb'
27
- RB_SDK_FOLDER='lib'
28
- MAX_REDIRECT_SDK=2
29
- private_constant :MAX_REDIRECT_SDK
31
+ EXT_RUBY_PROTOBUF = '_pb.rb'
32
+ RB_SDK_FOLDER = 'lib'
33
+ ONE_YEAR_SECONDS = 365 * 24 * 60 * 60
34
+ DEFAULT_ASPERA_CONF = <<~END_OF_CONFIG_FILE
35
+ <?xml version='1.0' encoding='UTF-8'?>
36
+ <CONF version="2">
37
+ <default>
38
+ <file_system>
39
+ <resume_suffix>.aspera-ckpt</resume_suffix>
40
+ <partial_file_suffix>.partial</partial_file_suffix>
41
+ </file_system>
42
+ </default>
43
+ </CONF>
44
+ END_OF_CONFIG_FILE
45
+ DUMMY_CERT_INFO='/C=US/ST=California/L=Emeryville/O=Aspera Inc./OU=Corporate/CN=Aspera Inc./emailAddress=info@asperasoft.com'
46
+ private_constant :PRODUCT_CONNECT,:PRODUCT_CLI_V1,:PRODUCT_DRIVE,:PRODUCT_ENTSRV,:EXT_RUBY_PROTOBUF,:RB_SDK_FOLDER,
47
+ :ONE_YEAR_SECONDS,:DEFAULT_ASPERA_CONF,:DUMMY_CERT_INFO
30
48
  # set ascp executable path
31
49
  def ascp_path=(v)
32
- @path_to_ascp=v
50
+ @path_to_ascp = v
51
+ end
52
+
53
+ def ascp_path
54
+ path(:ascp)
33
55
  end
34
56
 
35
57
  def sdk_ruby_folder
36
- ruby_pb_folder=File.join(folder_path,RB_SDK_FOLDER)
58
+ ruby_pb_folder = File.join(sdk_folder,RB_SDK_FOLDER)
37
59
  FileUtils.mkdir_p(ruby_pb_folder) unless Dir.exist?(ruby_pb_folder)
38
60
  return ruby_pb_folder
39
61
  end
40
62
 
41
63
  # location of SDK files
42
- def folder=(v)
43
- @sdk_folder=v
44
- folder_path
64
+ def sdk_folder=(v)
65
+ @sdk_dir = v
66
+ sdk_folder
67
+ end
68
+
69
+ # backward compatibility in sample program
70
+ alias_method :folder=, :sdk_folder=
71
+
72
+ # @return the path to folder where SDK is installed
73
+ def sdk_folder
74
+ raise 'SDK path was ot initialized' if @sdk_dir.nil?
75
+ FileUtils.mkdir_p(@sdk_dir) unless Dir.exist?(@sdk_dir)
76
+ @sdk_dir
45
77
  end
46
78
 
47
79
  # find ascp in named product (use value : FIRST_FOUND='FIRST' to just use first one)
48
80
  # or select one from installed_products()
49
81
  def use_ascp_from_product(product_name)
50
82
  if product_name.eql?(FIRST_FOUND)
51
- pl=installed_products.first
83
+ pl = installed_products.first
52
84
  raise "no FASP installation found\nPlease check manual on how to install FASP." if pl.nil?
53
85
  else
54
- pl=installed_products.select{|i|i[:name].eql?(product_name)}.first
86
+ pl = installed_products.find{|i|i[:name].eql?(product_name)}
55
87
  raise "no such product installed: #{product_name}" if pl.nil?
56
88
  end
57
- self.ascp_path=pl[:ascp_path]
89
+ self.ascp_path = pl[:ascp_path]
58
90
  Log.log.debug("ascp_path=#{@path_to_ascp}")
59
91
  end
60
92
 
61
93
  # @return the list of installed products in format of product_locations
62
94
  def installed_products
63
95
  if @found_products.nil?
64
- scan_locations=product_locations.clone
96
+ scan_locations = product_locations.clone
65
97
  # add SDK as first search path
66
98
  scan_locations.unshift({
67
- :expected =>'SDK',
68
- :app_root =>folder_path,
69
- :sub_bin =>''
99
+ expected: 'SDK',
100
+ app_root: sdk_folder,
101
+ sub_bin: ''
70
102
  })
71
103
  # search installed products: with ascp
72
- @found_products=scan_locations.select! do |item|
104
+ @found_products = scan_locations.select! do |item|
73
105
  # skip if not main folder
74
106
  next false unless Dir.exist?(item[:app_root])
75
107
  Log.log.debug("Found #{item[:app_root]}")
76
108
  sub_bin = item[:sub_bin] || BIN_SUBFOLDER
77
- item[:ascp_path]=File.join(item[:app_root],sub_bin,ascp_filename)
109
+ item[:ascp_path] = File.join(item[:app_root],sub_bin,ascp_filename)
78
110
  # skip if no ascp
79
111
  next false unless File.exist?(item[:ascp_path])
80
112
  # read info from product info file if present
81
- product_info_file="#{item[:app_root]}/#{PRODUCT_INFO}"
113
+ product_info_file = "#{item[:app_root]}/#{PRODUCT_INFO}"
82
114
  if File.exist?(product_info_file)
83
- res_s=XmlSimple.xml_in(File.read(product_info_file),{'ForceArray'=>false})
84
- item[:name]=res_s['name']
85
- item[:version]=res_s['version']
115
+ res_s = XmlSimple.xml_in(File.read(product_info_file),{'ForceArray' => false})
116
+ item[:name] = res_s['name']
117
+ item[:version] = res_s['version']
86
118
  else
87
- item[:name]=item[:expected]
119
+ item[:name] = item[:expected]
88
120
  end
89
121
  true # select this version
90
122
  end
@@ -93,7 +125,7 @@ module Aspera
93
125
  end
94
126
 
95
127
  # all ascp files (in SDK)
96
- FILES=[:ascp,:ascp4,:ssh_bypass_key_dsa,:ssh_bypass_key_rsa,:aspera_license,:aspera_conf,:fallback_cert,:fallback_key]
128
+ FILES = %i[ascp ascp4 ssh_bypass_key_dsa ssh_bypass_key_rsa aspera_license aspera_conf fallback_cert fallback_key].freeze
97
129
 
98
130
  # get path of one resource file of currently activated product
99
131
  # keys and certs are generated locally... (they are well known values, arch. independant)
@@ -101,51 +133,49 @@ module Aspera
101
133
  case k
102
134
  when :ascp,:ascp4
103
135
  use_ascp_from_product(FIRST_FOUND) if @path_to_ascp.nil?
104
- file=@path_to_ascp
136
+ file = @path_to_ascp
105
137
  # note that there might be a .exe at the end
106
- file=file.gsub('ascp','ascp4') if k.eql?(:ascp4)
138
+ file = file.gsub('ascp','ascp4') if k.eql?(:ascp4)
107
139
  when :transferd
108
- file=transferd_filepath
140
+ file = transferd_filepath
109
141
  when :ssh_bypass_key_dsa
110
- file=File.join(folder_path,'aspera_bypass_dsa.pem')
142
+ file = File.join(sdk_folder,'aspera_bypass_dsa.pem')
111
143
  File.write(file,get_key('dsa',1)) unless File.exist?(file)
112
144
  File.chmod(0400,file)
113
145
  when :ssh_bypass_key_rsa
114
- file=File.join(folder_path,'aspera_bypass_rsa.pem')
146
+ file = File.join(sdk_folder,'aspera_bypass_rsa.pem')
115
147
  File.write(file,get_key('rsa',2)) unless File.exist?(file)
116
148
  File.chmod(0400,file)
117
149
  when :aspera_license
118
- file=File.join(folder_path,'aspera-license')
119
- File.write(file,Base64.strict_encode64("#{Zlib::Inflate.inflate(DataRepository.instance.get_bin(6))}==SIGNATURE==\n#{Base64.strict_encode64(DataRepository.instance.get_bin(7))}")) unless File.exist?(file)
150
+ file = File.join(sdk_folder,'aspera-license')
151
+ unless File.exist?(file)
152
+ clear=[
153
+ Zlib::Inflate.inflate(DataRepository.instance.data(6)),
154
+ "==SIGNATURE==\n",
155
+ Base64.strict_encode64(DataRepository.instance.data(7))
156
+ ]
157
+ File.write(file,Base64.strict_encode64(clear.join))
158
+ end
120
159
  File.chmod(0400,file)
121
160
  when :aspera_conf
122
- file=File.join(folder_path,'aspera.conf')
123
- File.write(file,%Q{<?xml version='1.0' encoding='UTF-8'?>
124
- <CONF version="2">
125
- <default>
126
- <file_system>
127
- <resume_suffix>.aspera-ckpt</resume_suffix>
128
- <partial_file_suffix>.partial</partial_file_suffix>
129
- </file_system>
130
- </default>
131
- </CONF>
132
- }) unless File.exist?(file)
161
+ file = File.join(sdk_folder,'aspera.conf')
162
+ File.write(file,DEFAULT_ASPERA_CONF) unless File.exist?(file)
133
163
  File.chmod(0400,file)
134
164
  when :fallback_cert,:fallback_key
135
- file_key=File.join(folder_path,'aspera_fallback_key.pem')
136
- file_cert=File.join(folder_path,'aspera_fallback_cert.pem')
137
- if !File.exist?(file_key) or !File.exist?(file_cert)
165
+ file_key = File.join(sdk_folder,'aspera_fallback_key.pem')
166
+ file_cert = File.join(sdk_folder,'aspera_fallback_cert.pem')
167
+ if !File.exist?(file_key) || !File.exist?(file_cert)
138
168
  require 'openssl'
139
169
  # create new self signed certificate for http fallback
140
170
  private_key = OpenSSL::PKey::RSA.new(1024)
141
171
  cert = OpenSSL::X509::Certificate.new
142
- cert.subject = cert.issuer = OpenSSL::X509::Name.parse("/C=US/ST=California/L=Emeryville/O=Aspera Inc./OU=Corporate/CN=Aspera Inc./emailAddress=info@asperasoft.com")
172
+ cert.subject = cert.issuer = OpenSSL::X509::Name.parse(DUMMY_CERT_INFO)
143
173
  cert.not_before = Time.now
144
- cert.not_after = Time.now + 365 * 24 * 60 * 60
174
+ cert.not_after = Time.now + ONE_YEAR_SECONDS
145
175
  cert.public_key = private_key.public_key
146
176
  cert.serial = 0x0
147
177
  cert.version = 2
148
- cert.sign(private_key, OpenSSL::Digest::SHA1.new)
178
+ cert.sign(private_key, OpenSSL::Digest.new('SHA1'))
149
179
  File.write(file_key,private_key.to_pem)
150
180
  File.write(file_cert,cert.to_pem)
151
181
  File.chmod(0400,file_key)
@@ -161,13 +191,13 @@ module Aspera
161
191
 
162
192
  # @return the file path of local connect where API's URI can be read
163
193
  def connect_uri
164
- connect=get_product_folders(PRODUCT_CONNECT)
165
- folder=File.join(connect[:run_root],VARRUN_SUBFOLDER)
194
+ connect = get_product_folders(PRODUCT_CONNECT)
195
+ folder = File.join(connect[:run_root],VARRUN_SUBFOLDER)
166
196
  ['','s'].each do |ext|
167
- uri_file=File.join(folder,"http#{ext}.uri")
197
+ uri_file = File.join(folder,"http#{ext}.uri")
168
198
  Log.log.debug("checking connect port file: #{uri_file}")
169
199
  if File.exist?(uri_file)
170
- return File.open(uri_file){|f|f.gets}.strip
200
+ return File.open(uri_file, &:gets).strip
171
201
  end
172
202
  end
173
203
  raise "no connect uri file found in #{folder}"
@@ -175,17 +205,17 @@ module Aspera
175
205
 
176
206
  # @ return path to configuration file of aspera CLI
177
207
  def cli_conf_file
178
- connect=get_product_folders(PRODUCT_CLI_V1)
208
+ connect = get_product_folders(PRODUCT_CLI_V1)
179
209
  return File.join(connect[:app_root],BIN_SUBFOLDER,'.aspera_cli_conf')
180
210
  end
181
211
 
182
212
  # default bypass key phrase
183
213
  def bypass_pass
184
- return "%08x-%04x-%04x-%04x-%04x%08x" % DataRepository.instance.get_bin(3).unpack("NnnnnN")
214
+ return format('%08x-%04x-%04x-%04x-%04x%08x',*DataRepository.instance.data(3).unpack('NnnnnN'))
185
215
  end
186
216
 
187
217
  def bypass_keys
188
- return [:ssh_bypass_key_dsa,:ssh_bypass_key_rsa].map{|i|Installation.instance.path(i)}
218
+ return %i[ssh_bypass_key_dsa ssh_bypass_key_rsa].map{|i|Installation.instance.path(i)}
189
219
  end
190
220
 
191
221
  # use in plugin `config`
@@ -195,14 +225,14 @@ module Aspera
195
225
 
196
226
  # Check that specified path is ascp and get version
197
227
  def get_exe_version(exe_path,vers_arg)
198
- raise "ERROR: nil arg" if exe_path.nil?
228
+ raise 'ERROR: nil arg' if exe_path.nil?
199
229
  return nil unless File.exist?(exe_path)
200
- exe_version=nil
201
- cmd_out=%x{"#{exe_path}" #{vers_arg}}
202
- raise "An error occured when testing #{ascp_filename}: #{cmd_out}" unless $? == 0
230
+ exe_version = nil
231
+ cmd_out = %x("#{exe_path}" #{vers_arg})
232
+ raise "An error occured when testing #{ascp_filename}: #{cmd_out}" unless $CHILD_STATUS == 0
203
233
  # get version from ascp, only after full extract, as windows requires DLLs (SSL/TLS/etc...)
204
- m=cmd_out.match(/ version ([0-9\.]+)/)
205
- exe_version=m[1] unless m.nil?
234
+ m = cmd_out.match(/ version ([0-9.]+)/)
235
+ exe_version = m[1] unless m.nil?
206
236
  return exe_version
207
237
  end
208
238
 
@@ -211,97 +241,89 @@ module Aspera
211
241
  # @return ascp version (from execution)
212
242
  def install_sdk(sdk_url)
213
243
  require 'zip'
214
- sdk_zip_path=File.join(Dir.tmpdir,'sdk.zip')
244
+ sdk_zip_path = File.join(Dir.tmpdir,'sdk.zip')
215
245
  if sdk_url.start_with?('file:')
216
246
  # require specific file scheme: the path part is "relative", or absolute if there are 4 slash
217
247
  raise 'use format: file:///<path>' unless sdk_url.start_with?('file:///')
218
- sdk_zip_path=sdk_url.gsub(%r{^file:///},'')
248
+ sdk_zip_path = sdk_url.gsub(%r{^file:///},'')
219
249
  else
220
250
  Aspera::Rest.new(base_url: sdk_url, redirect_max: 3).call(operation: 'GET',save_to_file: sdk_zip_path)
221
251
  end
222
252
  # rename old install
223
- if ! Dir.empty?(folder_path)
224
- Log.log.warn("Previous install exists, renaming folder.")
225
- File.rename(folder_path,"#{folder_path}.#{Time.now.strftime("%Y%m%d%H%M%S")}")
253
+ if !Dir.empty?(sdk_folder)
254
+ Log.log.warn('Previous install exists, renaming folder.')
255
+ File.rename(sdk_folder,"#{sdk_folder}.#{Time.now.strftime('%Y%m%d%H%M%S')}")
226
256
  # TODO: delete old archives ?
227
257
  end
228
258
  # SDK is organized by architecture
229
- arch_filter="#{Environment.architecture}/"
259
+ arch_filter = "#{Environment.architecture}/"
230
260
  # extract files from archive
231
261
  Zip::File.open(sdk_zip_path) do |zip_file|
232
262
  zip_file.each do |entry|
233
263
  # skip folder entries
234
264
  next if entry.name.end_with?('/')
235
- dest_folder=nil
265
+ dest_folder = nil
236
266
  # binaries
237
- dest_folder=folder_path if entry.name.include?(arch_filter)
267
+ dest_folder = sdk_folder if entry.name.include?(arch_filter)
238
268
  # ruby adapters
239
- dest_folder=sdk_ruby_folder if entry.name.end_with?(EXT_RUBY_PROTOBUF)
240
- if !dest_folder.nil?
241
- File.open(File.join(dest_folder,File.basename(entry.name)), 'wb') do |output_stream|
242
- IO.copy_stream(entry.get_input_stream, output_stream)
243
- end
269
+ dest_folder = sdk_ruby_folder if entry.name.end_with?(EXT_RUBY_PROTOBUF)
270
+ next if dest_folder.nil?
271
+ File.open(File.join(dest_folder,File.basename(entry.name)), 'wb') do |output_stream|
272
+ IO.copy_stream(entry.get_input_stream, output_stream)
244
273
  end
245
274
  end
246
275
  end
247
276
  File.unlink(sdk_zip_path) rescue nil # Windows may give error
248
277
  # ensure license file are generated so that ascp invokation for version works
249
- self.path(:aspera_license)
250
- self.path(:aspera_conf)
251
- ascp_path=File.join(folder_path,ascp_filename)
278
+ path(:aspera_license)
279
+ path(:aspera_conf)
280
+ ascp_path = File.join(sdk_folder,ascp_filename)
252
281
  raise "No #{ascp_filename} found in SDK archive" unless File.exist?(ascp_path)
253
282
  FileUtils.chmod(0755,ascp_path)
254
283
  FileUtils.chmod(0755,ascp_path.gsub('ascp','ascp4'))
255
- ascp_version=get_ascp_version(File.join(folder_path,ascp_filename))
256
- trd_path=transferd_filepath
284
+ ascp_version = get_ascp_version(File.join(sdk_folder,ascp_filename))
285
+ trd_path = transferd_filepath
257
286
  Log.log.warn("No #{trd_path} in SDK archive") unless File.exist?(trd_path)
258
287
  FileUtils.chmod(0755,trd_path) if File.exist?(trd_path)
259
- transferd_version=get_exe_version(trd_path,'version')
260
- sdk_version = transferd_version||ascp_version
261
- File.write(File.join(folder_path,PRODUCT_INFO),"<product><name>IBM Aspera SDK</name><version>#{sdk_version}</version></product>")
288
+ transferd_version = get_exe_version(trd_path,'version')
289
+ sdk_version = transferd_version || ascp_version
290
+ File.write(File.join(sdk_folder,PRODUCT_INFO),"<product><name>IBM Aspera SDK</name><version>#{sdk_version}</version></product>")
262
291
  return sdk_version
263
292
  end
264
293
 
265
294
  private
266
295
 
267
- BIN_SUBFOLDER='bin'
268
- ETC_SUBFOLDER='etc'
269
- VARRUN_SUBFOLDER=File.join('var','run')
296
+ BIN_SUBFOLDER = 'bin'
297
+ ETC_SUBFOLDER = 'etc'
298
+ VARRUN_SUBFOLDER = File.join('var','run')
270
299
  # product information manifest: XML (part of aspera product)
271
- PRODUCT_INFO='product-info.mf'
300
+ PRODUCT_INFO = 'product-info.mf'
272
301
  # policy for product selection
273
- FIRST_FOUND='FIRST'
302
+ FIRST_FOUND = 'FIRST'
274
303
 
275
304
  private_constant :BIN_SUBFOLDER,:ETC_SUBFOLDER,:VARRUN_SUBFOLDER,:PRODUCT_INFO
276
305
 
277
306
  def initialize
278
- @path_to_ascp=nil
279
- @sdk_folder=nil
280
- @found_products=nil
307
+ @path_to_ascp = nil
308
+ @sdk_dir = nil
309
+ @found_products = nil
281
310
  end
282
311
 
283
312
  # @return folder paths for specified applications
284
313
  # @param name Connect or CLI
285
314
  def get_product_folders(name)
286
- found=installed_products.select{|i|i[:expected].eql?(name) or i[:name].eql?(name)}
315
+ found = installed_products.select{|i|i[:expected].eql?(name) || i[:name].eql?(name)}
287
316
  raise "Product: #{name} not found, please install." if found.empty?
288
317
  return found.first
289
318
  end
290
319
 
291
- # @return the path to folder where SDK is installed
292
- def folder_path
293
- raise "Undefined path to SDK" if @sdk_folder.nil?
294
- FileUtils.mkdir_p(@sdk_folder) unless Dir.exist?(@sdk_folder)
295
- @sdk_folder
296
- end
297
-
298
320
  # filename for ascp with optional extension (Windows)
299
321
  def ascp_filename
300
- return 'ascp'+Environment.exe_extension
322
+ return 'ascp' + Environment.exe_extension
301
323
  end
302
324
 
303
325
  def transferd_filepath
304
- return File.join(folder_path,'asperatransferd'+Environment.exe_extension)
326
+ return File.join(sdk_folder,'asperatransferd' + Environment.exe_extension)
305
327
  end
306
328
 
307
329
  # @return product folders depending on OS fields
@@ -313,50 +335,50 @@ module Aspera
313
335
  def product_locations
314
336
  case Aspera::Environment.os
315
337
  when Aspera::Environment::OS_WINDOWS; return [{
316
- :expected =>PRODUCT_CONNECT,
317
- :app_root =>File.join(ENV['LOCALAPPDATA'],'Programs','Aspera','Aspera Connect'),
318
- :log_root =>File.join(ENV['LOCALAPPDATA'],'Aspera','Aspera Connect','var','log'),
319
- :run_root =>File.join(ENV['LOCALAPPDATA'],'Aspera','Aspera Connect')
320
- },{
321
- :expected =>PRODUCT_CLI_V1,
322
- :app_root =>File.join('C:','Program Files','Aspera','cli'),
323
- :log_root =>File.join('C:','Program Files','Aspera','cli','var','log'),
324
- },{
325
- :expected =>PRODUCT_ENTSRV,
326
- :app_root =>File.join('C:','Program Files','Aspera','Enterprise Server'),
327
- :log_root =>File.join('C:','Program Files','Aspera','Enterprise Server','var','log'),
328
- }]
338
+ expected: PRODUCT_CONNECT,
339
+ app_root: File.join(ENV['LOCALAPPDATA'],'Programs','Aspera','Aspera Connect'),
340
+ log_root: File.join(ENV['LOCALAPPDATA'],'Aspera','Aspera Connect','var','log'),
341
+ run_root: File.join(ENV['LOCALAPPDATA'],'Aspera','Aspera Connect')
342
+ },{
343
+ expected: PRODUCT_CLI_V1,
344
+ app_root: File.join('C:','Program Files','Aspera','cli'),
345
+ log_root: File.join('C:','Program Files','Aspera','cli','var','log')
346
+ },{
347
+ expected: PRODUCT_ENTSRV,
348
+ app_root: File.join('C:','Program Files','Aspera','Enterprise Server'),
349
+ log_root: File.join('C:','Program Files','Aspera','Enterprise Server','var','log')
350
+ }]
329
351
  when Aspera::Environment::OS_X; return [{
330
- :expected =>PRODUCT_CONNECT,
331
- :app_root =>File.join(Dir.home,'Applications','Aspera Connect.app'),
332
- :log_root =>File.join(Dir.home,'Library','Logs','Aspera_Connect'),
333
- :run_root =>File.join(Dir.home,'Library','Application Support','Aspera','Aspera Connect'),
334
- :sub_bin =>File.join('Contents','Resources'),
335
- },{
336
- :expected =>PRODUCT_CLI_V1,
337
- :app_root =>File.join(Dir.home,'Applications','Aspera CLI'),
338
- :log_root =>File.join(Dir.home,'Library','Logs','Aspera')
339
- },{
340
- :expected =>PRODUCT_ENTSRV,
341
- :app_root =>File.join('','Library','Aspera'),
342
- :log_root =>File.join(Dir.home,'Library','Logs','Aspera'),
343
- },{
344
- :expected =>PRODUCT_DRIVE,
345
- :app_root =>File.join('','Applications','Aspera Drive.app'),
346
- :log_root =>File.join(Dir.home,'Library','Logs','Aspera_Drive'),
347
- :sub_bin =>File.join('Contents','Resources'),
348
- }]
349
- else; return [{ # other: Linux and Unix family
350
- :expected =>PRODUCT_CONNECT,
351
- :app_root =>File.join(Dir.home,'.aspera','connect'),
352
- :run_root =>File.join(Dir.home,'.aspera','connect')
353
- },{
354
- :expected =>PRODUCT_CLI_V1,
355
- :app_root =>File.join(Dir.home,'.aspera','cli'),
356
- },{
357
- :expected =>PRODUCT_ENTSRV,
358
- :app_root =>File.join('','opt','aspera'),
359
- }]
352
+ expected: PRODUCT_CONNECT,
353
+ app_root: File.join(Dir.home,'Applications','Aspera Connect.app'),
354
+ log_root: File.join(Dir.home,'Library','Logs','Aspera_Connect'),
355
+ run_root: File.join(Dir.home,'Library','Application Support','Aspera','Aspera Connect'),
356
+ sub_bin: File.join('Contents','Resources')
357
+ },{
358
+ expected: PRODUCT_CLI_V1,
359
+ app_root: File.join(Dir.home,'Applications','Aspera CLI'),
360
+ log_root: File.join(Dir.home,'Library','Logs','Aspera')
361
+ },{
362
+ expected: PRODUCT_ENTSRV,
363
+ app_root: File.join('','Library','Aspera'),
364
+ log_root: File.join(Dir.home,'Library','Logs','Aspera')
365
+ },{
366
+ expected: PRODUCT_DRIVE,
367
+ app_root: File.join('','Applications','Aspera Drive.app'),
368
+ log_root: File.join(Dir.home,'Library','Logs','Aspera_Drive'),
369
+ sub_bin: File.join('Contents','Resources')
370
+ }]
371
+ else; return [{ # other: Linux and Unix family
372
+ expected: PRODUCT_CONNECT,
373
+ app_root: File.join(Dir.home,'.aspera','connect'),
374
+ run_root: File.join(Dir.home,'.aspera','connect')
375
+ },{
376
+ expected: PRODUCT_CLI_V1,
377
+ app_root: File.join(Dir.home,'.aspera','cli')
378
+ },{
379
+ expected: PRODUCT_ENTSRV,
380
+ app_root: File.join('','opt','aspera')
381
+ }]
360
382
  end
361
383
  end
362
384
 
@@ -364,11 +386,9 @@ module Aspera
364
386
  # @param type rsa or dsa
365
387
  # @param id in repository 1 for dsa, 2 for rsa
366
388
  def get_key(type,id)
367
- hf=['begin','end'].map{|t|"-----#{t} #{type} private key-----".upcase}
368
- bin=Base64.strict_encode64(DataRepository.instance.get_bin(id))
369
- hf.insert(1,bin).join("\n")
389
+ # generate PEM from DER
390
+ OpenSSL::PKey.const_get(type.upcase).new(DataRepository.instance.data(id)).to_pem
370
391
  end
371
-
372
392
  end # Installation
373
393
  end
374
394
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aspera
2
4
  module Fasp
3
5
  # imlement this class to get transfer events