Class: Nexpose::AdminCredentials

Inherits:
Object
  • Object
show all
Includes:
Comparable, XMLUtils
Defined in:
lib/nexpose/creds.rb

Overview

Object that represents administrative credentials to be used during a scan. When retrieved from an existing site configuration the credentials will be returned as a security blob and can only be passed back as is during a Site Save operation. This object can only be used to create a new set of credentials.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XMLUtils

#make_xml, #parse_xml

Constructor Details

#initialize(isblob = false) ⇒ AdminCredentials

Returns a new instance of AdminCredentials.



34
35
36
# File 'lib/nexpose/creds.rb', line 34

def initialize(isblob = false)
  @isblob = isblob
end

Instance Attribute Details

#headersObject (readonly)

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



29
30
31
# File 'lib/nexpose/creds.rb', line 29

def headers
  @headers
end

#hostObject (readonly)

The host for these credentials. Can be Any.



18
19
20
# File 'lib/nexpose/creds.rb', line 18

def host
  @host
end

#html_formsObject (readonly)

When using htmlforms, this represents the tho form to pass the authentication request to.



32
33
34
# File 'lib/nexpose/creds.rb', line 32

def html_forms
  @html_forms
end

#isblobObject (readonly)

Designates if this object contains user defined credentials or a security blob



14
15
16
# File 'lib/nexpose/creds.rb', line 14

def isblob
  @isblob
end

#passwordObject (readonly)

The password



24
25
26
# File 'lib/nexpose/creds.rb', line 24

def password
  @password
end

#portObject (readonly)

The port on which to use these credentials.



20
21
22
# File 'lib/nexpose/creds.rb', line 20

def port
  @port
end

#realmObject (readonly)

The realm for these credentials



26
27
28
# File 'lib/nexpose/creds.rb', line 26

def realm
  @realm
end

#securityblobObject (readonly)

Security blob for an existing set of credentials



12
13
14
# File 'lib/nexpose/creds.rb', line 12

def securityblob
  @securityblob
end

#serviceObject (readonly)

The service for these credentials. Can be All.



16
17
18
# File 'lib/nexpose/creds.rb', line 16

def service
  @service
end

#useridObject (readonly)

The user id or username



22
23
24
# File 'lib/nexpose/creds.rb', line 22

def userid
  @userid
end

Instance Method Details

#<=>(other) ⇒ Object



97
98
99
# File 'lib/nexpose/creds.rb', line 97

def <=>(other)
  to_xml <=> other.to_xml
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/nexpose/creds.rb', line 101

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

#hashObject



105
106
107
# File 'lib/nexpose/creds.rb', line 105

def hash
  to_xml.hash
end

#set_blob(securityblob) ⇒ Object

TODO: add description



60
61
62
63
# File 'lib/nexpose/creds.rb', line 60

def set_blob(securityblob)
  @isblob = true
  @securityblob = securityblob
end

#set_credentials(service, host, port, userid, password, realm) ⇒ Object

Sets the credentials information for this object.



39
40
41
42
43
44
45
46
47
48
# File 'lib/nexpose/creds.rb', line 39

def set_credentials(service, host, port, userid, password, realm)
  @isblob = false
  @securityblob = nil
  @service = service
  @host = host
  @port = port
  @userid = userid
  @password = password
  @realm = realm
end

#set_headers(headers) ⇒ Object

Add Headers to credentials for httpheaders.



66
67
68
# File 'lib/nexpose/creds.rb', line 66

def set_headers(headers)
  @headers = headers
end

#set_host(host) ⇒ Object



55
56
57
# File 'lib/nexpose/creds.rb', line 55

def set_host(host)
  @host = host
end

#set_html_forms(html_forms) ⇒ Object



70
71
72
# File 'lib/nexpose/creds.rb', line 70

def set_html_forms(html_forms)
  @html_forms = html_forms
end

#set_service(service) ⇒ Object

TODO: add description



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

def set_service(service)
  @service = service
end

#to_xmlObject



74
75
76
# File 'lib/nexpose/creds.rb', line 74

def to_xml
  to_xml_elem.to_s
end

#to_xml_elemObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/nexpose/creds.rb', line 78

def to_xml_elem
  attributes = {}

  attributes['service'] = @service
  attributes['userid'] = @userid
  attributes['password'] = @password
  attributes['realm'] = @realm
  attributes['host'] = @host
  attributes['port'] = @port

  data = isblob ? securityblob : ''
  xml = make_xml('adminCredentials', attributes, data)
  xml.add_element(@headers.to_xml_elem) if @headers
  xml.add_element(@html_forms.to_xml_elem) if @html_forms
  xml
end