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.



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

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.



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

def baseURL
  @baseURL
end

#enabledObject

is this enable for the site configuration



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

def enabled
  @enabled
end

#headersObject (readonly)

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



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

def headers
  @headers
end

#idObject (readonly)

id of the header



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

def id
  @id
end

#nameObject (readonly)

name of the html header



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

def name
  @name
end

#serviceObject (readonly)

service type of header



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

def service
  @service
end

#soft403PatternObject (readonly)

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



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

def soft403Pattern
  @soft403Pattern
end

Instance Method Details

#==(other) ⇒ Object



83
84
85
# File 'lib/nexpose/web_credentials.rb', line 83

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

#add_header(header) ⇒ Object



65
66
67
# File 'lib/nexpose/web_credentials.rb', line 65

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
90
91
92
93
94
95
# File 'lib/nexpose/web_credentials.rb', line 87

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



73
74
75
76
77
78
79
80
81
# File 'lib/nexpose/web_credentials.rb', line 73

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

#to_jsonObject



69
70
71
# File 'lib/nexpose/web_credentials.rb', line 69

def to_json
  JSON.generate(to_h)
end