Class: Nexpose::WebCredentials::Headers

Inherits:
APIObject
  • Object
show all
Defined in:
lib/nexpose/web_credentials.rb

Overview

Object that represents Headers, associated with Web Session Authentication.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from APIObject

#object_from_hash

Constructor Details

#initialize(name, baseURL, soft403Pattern, id = -1,, enabled = true) ⇒ Headers

Returns a new instance of Headers.



57
58
59
60
61
62
63
64
65
# File 'lib/nexpose/web_credentials.rb', line 57

def initialize(name, baseURL, soft403Pattern, id = -1, enabled = true)
  @headers = {}
  @name = name
  @baseURL = baseURL
  @soft403Pattern = soft403Pattern
  @service = WebAppAuthType::HTTP_HEADER
  @enabled = enabled
  @id = id
end

Instance Attribute Details

#baseURLObject (readonly)

Base URL of the application for which the form authentication applies.



44
45
46
# File 'lib/nexpose/web_credentials.rb', line 44

def baseURL
  @baseURL
end

#enabledObject

is this enable for the site configuration



50
51
52
# File 'lib/nexpose/web_credentials.rb', line 50

def enabled
  @enabled
end

#headersObject (readonly)

When using HTTP headers, this represents the set of headers to pass with the authentication request.



46
47
48
# File 'lib/nexpose/web_credentials.rb', line 46

def headers
  @headers
end

#idObject (readonly)

id of the header



54
55
56
# File 'lib/nexpose/web_credentials.rb', line 54

def id
  @id
end

#nameObject (readonly)

name of the html header



48
49
50
# File 'lib/nexpose/web_credentials.rb', line 48

def name
  @name
end

#serviceObject (readonly)

service type of header



52
53
54
# File 'lib/nexpose/web_credentials.rb', line 52

def service
  @service
end

#soft403PatternObject (readonly)

A regular expression used to match against the response to identify authentication failures.



42
43
44
# File 'lib/nexpose/web_credentials.rb', line 42

def soft403Pattern
  @soft403Pattern
end

Instance Method Details

#==(other) ⇒ Object



86
87
88
# File 'lib/nexpose/web_credentials.rb', line 86

def ==(other)
  eql?(other)
end

#add_header(header) ⇒ Object



67
68
69
# File 'lib/nexpose/web_credentials.rb', line 67

def add_header(header)
  @headers = @headers.merge(header.to_h)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
93
94
95
96
97
98
# File 'lib/nexpose/web_credentials.rb', line 90

def eql?(other)
  id.eql?(other.id) &&
  service.eql?(other.service) &&
  enabled.eql?(other.enabled) &&
  name.eql?(other.name) &&
  headers.eql?(other.headers) &&
  baseURL.eql?(other.baseURL) &&
  soft403Pattern.eql?(other.soft403Pattern)
end

#to_hObject



75
76
77
78
79
80
81
82
83
84
# File 'lib/nexpose/web_credentials.rb', line 75

def to_h
  { id: id,
    service: service,
    enabled: enabled,
    name: name,
    headers: headers,
    baseURL: baseURL,
    soft403Pattern: soft403Pattern
  }
end

#to_jsonObject



71
72
73
# File 'lib/nexpose/web_credentials.rb', line 71

def to_json
  JSON.generate(to_h)
end