Class: Aspera::Cli::BasicAuthPlugin

Inherits:
Plugin
  • Object
show all
Defined in:
lib/aspera/cli/basic_auth_plugin.rb

Overview

base class for applications supporting basic authentication

Constant Summary collapse

ACTIONS =
[]

Constants inherited from Plugin

Plugin::ALL_OPS, Plugin::GLOBAL_OPS, Plugin::INSTANCE_OPS

Instance Method Summary collapse

Methods inherited from Plugin

#config, #entity_action, #entity_command, #format, #options, #transfer

Constructor Details

#initialize(env) ⇒ BasicAuthPlugin



8
9
10
11
12
13
14
15
16
# File 'lib/aspera/cli/basic_auth_plugin.rb', line 8

def initialize(env)
  super(env)
  unless env[:skip_basic_auth_options]
    self.options.add_opt_simple(:url,"URL of application, e.g. https://org.asperafiles.com")
    self.options.add_opt_simple(:username,"username to log in")
    self.options.add_opt_simple(:password,"user's password")
    self.options.parse_options!
  end
end

Instance Method Details

#basic_auth_api(subpath = nil) ⇒ Object

returns a Rest object with basic auth



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/aspera/cli/basic_auth_plugin.rb', line 24

def basic_auth_api(subpath=nil)
  api_url=self.options.get_option(:url,:mandatory)
  api_url=api_url+'/'+subpath unless subpath.nil?
  return Rest.new({
    :base_url => api_url,
    :auth     => {
    :type     => :basic,
    :username => self.options.get_option(:username,:mandatory),
    :password => self.options.get_option(:password,:mandatory)
    }})
end

#execute_actionObject



19
20
21
# File 'lib/aspera/cli/basic_auth_plugin.rb', line 19

def execute_action
  raise "do not execute action on this generic plugin"
end