Class: Nexpose::ExportCredential

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

Overview

DBExport credentials configuration object.

The user_id, password and realm attributes should ONLY be used if a security blob cannot be generated and the data is being transmitted/stored using external encryption (e.g., HTTPS).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credential) ⇒ ExportCredential

Returns a new instance of ExportCredential.



561
562
563
# File 'lib/nexpose/report.rb', line 561

def initialize(credential)
  @credential = credential
end

Instance Attribute Details

#credentialObject

Security blob for exporting to a database.



555
556
557
# File 'lib/nexpose/report.rb', line 555

def credential
  @credential
end

#passwordObject

Returns the value of attribute password.



557
558
559
# File 'lib/nexpose/report.rb', line 557

def password
  @password
end

#realmObject

DB specific, usually the database name.



559
560
561
# File 'lib/nexpose/report.rb', line 559

def realm
  @realm
end

#user_idObject

Returns the value of attribute user_id.



556
557
558
# File 'lib/nexpose/report.rb', line 556

def user_id
  @user_id
end

Class Method Details

.parse(xml) ⇒ Object



575
576
577
578
579
580
581
582
583
584
585
# File 'lib/nexpose/report.rb', line 575

def self.parse(xml)
  xml.elements.each('//credentials') do |creds|
    credential = ExportCredential.new(creds.text)
    # The following attributes may not exist.
    credential.user_id = creds.attributes['userid']
    credential.password = creds.attributes['password']
    credential.realm = creds.attributes['realm']
    return credential
  end
  nil
end

Instance Method Details

#to_xmlObject



565
566
567
568
569
570
571
572
573
# File 'lib/nexpose/report.rb', line 565

def to_xml
  xml = '<credentials'
  xml << %Q{ userid='#{@user_id}'} if @user_id
  xml << %Q{ password='#{@password}'} if @password
  xml << %Q{ realm='#{@realm}'} if @realm
  xml << '>'
  xml << @credential if @credential
  xml << '</credentials>'
end