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.



601
602
603
# File 'lib/nexpose/report.rb', line 601

def initialize(credential)
  @credential = credential
end

Instance Attribute Details

#credentialObject

Security blob for exporting to a database.



595
596
597
# File 'lib/nexpose/report.rb', line 595

def credential
  @credential
end

#passwordObject

Returns the value of attribute password.



597
598
599
# File 'lib/nexpose/report.rb', line 597

def password
  @password
end

#realmObject

DB specific, usually the database name.



599
600
601
# File 'lib/nexpose/report.rb', line 599

def realm
  @realm
end

#user_idObject

Returns the value of attribute user_id.



596
597
598
# File 'lib/nexpose/report.rb', line 596

def user_id
  @user_id
end

Class Method Details

.parse(xml) ⇒ Object



615
616
617
618
619
620
621
622
623
624
625
# File 'lib/nexpose/report.rb', line 615

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



605
606
607
608
609
610
611
612
613
# File 'lib/nexpose/report.rb', line 605

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