Class: TrainPlugins::Rest::AuthHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/train-rest/auth_handler.rb

Overview

Class to derive authentication handlers from.

Direct Known Subclasses

Anonymous, AuthtypeApikey, Basic, Bearer, Header, Redfish

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection = nil) ⇒ AuthHandler

Returns a new instance of AuthHandler.


8
9
10
# File 'lib/train-rest/auth_handler.rb', line 8

def initialize(connection = nil)
  @connection = connection
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.


5
6
7
# File 'lib/train-rest/auth_handler.rb', line 5

def connection
  @connection
end

#optionsObject

Returns the value of attribute options.


6
7
8
# File 'lib/train-rest/auth_handler.rb', line 6

def options
  @options
end

Class Method Details

.descendantsArray

List authentication handlers

Returns:

  • (Array)

    Classes derived from ‘AuthHandler`


24
25
26
# File 'lib/train-rest/auth_handler.rb', line 24

def self.descendants
  ObjectSpace.each_object(Class).select { |klass| klass < self }
end

.nameString

Return name of handler

Returns:

  • (String)

15
16
17
18
19
# File 'lib/train-rest/auth_handler.rb', line 15

def self.name
  class_name = self.to_s.split("::").last

  convert_to_snake_case(class_name)
end

Instance Method Details

#auth_headersHash

Headers added to the rest-client call

Returns:

  • (Hash)

58
59
60
# File 'lib/train-rest/auth_handler.rb', line 58

def auth_headers
  {}
end

#auth_parametersHash

These will get added to the rest-client call.


66
67
68
# File 'lib/train-rest/auth_handler.rb', line 66

def auth_parameters
  { headers: auth_headers }
end

#check_optionsObject

Verify transport options

Raises:

  • (ArgumentError)

    if options are not as needed


39
# File 'lib/train-rest/auth_handler.rb', line 39

def check_options; end

#loginObject

Handle login


42
# File 'lib/train-rest/auth_handler.rb', line 42

def ; end

#logoutObject

Handle logout


53
# File 'lib/train-rest/auth_handler.rb', line 53

def logout; end

#renew_sessionObject

Handle session renewal


45
# File 'lib/train-rest/auth_handler.rb', line 45

def renew_session; end

#renewal_needed?Boolean

Return if session renewal needs to happen soon

Returns:

  • (Boolean)

50
# File 'lib/train-rest/auth_handler.rb', line 50

def renewal_needed?; end