Class: Nexpose::AdminCredentials
- Inherits:
-
Object
- Object
- Nexpose::AdminCredentials
- 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
-
#headers ⇒ Object
readonly
When using httpheaders, this represents the set of headers to pass with the authentication request.
-
#host ⇒ Object
readonly
The host for these credentials.
-
#html_forms ⇒ Object
readonly
When using htmlforms, this represents the tho form to pass the authentication request to.
-
#isblob ⇒ Object
readonly
Designates if this object contains user defined credentials or a security blob.
-
#password ⇒ Object
readonly
The password.
-
#port ⇒ Object
readonly
The port on which to use these credentials.
-
#realm ⇒ Object
readonly
The realm for these credentials.
-
#securityblob ⇒ Object
readonly
Security blob for an existing set of credentials.
-
#service ⇒ Object
readonly
The service for these credentials.
-
#userid ⇒ Object
readonly
The user id or username.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(isblob = false) ⇒ AdminCredentials
constructor
A new instance of AdminCredentials.
-
#set_blob(securityblob) ⇒ Object
TODO: add description.
-
#set_credentials(service, host, port, userid, password, realm) ⇒ Object
Sets the credentials information for this object.
-
#set_headers(headers) ⇒ Object
Add Headers to credentials for httpheaders.
- #set_host(host) ⇒ Object
- #set_html_forms(html_forms) ⇒ Object
-
#set_service(service) ⇒ Object
TODO: add description.
- #to_xml ⇒ Object
- #to_xml_elem ⇒ Object
Methods included from XMLUtils
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
#headers ⇒ Object (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 |
#host ⇒ Object (readonly)
The host for these credentials. Can be Any.
18 19 20 |
# File 'lib/nexpose/creds.rb', line 18 def host @host end |
#html_forms ⇒ Object (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 |
#isblob ⇒ Object (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 |
#password ⇒ Object (readonly)
The password
24 25 26 |
# File 'lib/nexpose/creds.rb', line 24 def password @password end |
#port ⇒ Object (readonly)
The port on which to use these credentials.
20 21 22 |
# File 'lib/nexpose/creds.rb', line 20 def port @port end |
#realm ⇒ Object (readonly)
The realm for these credentials
26 27 28 |
# File 'lib/nexpose/creds.rb', line 26 def realm @realm end |
#securityblob ⇒ Object (readonly)
Security blob for an existing set of credentials
12 13 14 |
# File 'lib/nexpose/creds.rb', line 12 def securityblob @securityblob end |
#service ⇒ Object (readonly)
The service for these credentials. Can be All.
16 17 18 |
# File 'lib/nexpose/creds.rb', line 16 def service @service end |
#userid ⇒ Object (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
101 102 103 |
# File 'lib/nexpose/creds.rb', line 101 def eql?(other) to_xml == other.to_xml end |
#hash ⇒ Object
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_xml ⇒ Object
74 75 76 |
# File 'lib/nexpose/creds.rb', line 74 def to_xml to_xml_elem.to_s end |
#to_xml_elem ⇒ Object
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 |