Class: OpenvasCli::VasLscCredential
- Defined in:
- lib/openvas-cli/vas_lsc_credential.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#in_use ⇒ Object
Returns the value of attribute in_use.
-
#login ⇒ Object
Returns the value of attribute login.
-
#name ⇒ Object
Returns the value of attribute name.
-
#package ⇒ Object
Returns the value of attribute package.
-
#package_type ⇒ Object
Returns the value of attribute package_type.
-
#password ⇒ Object
Returns the value of attribute password.
-
#password_confirmation ⇒ Object
Returns the value of attribute password_confirmation.
-
#public_key ⇒ Object
Returns the value of attribute public_key.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from VasBase
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from VasBase
#destroy, #destroy!, get_by_id, #initialize, #new_record?, #reset_changes, #save, #save!, #to_key, #to_param, #update_attributes
Methods included from ConnAddin
Methods included from XmlAddin
Constructor Details
This class inherits a constructor from OpenvasCli::VasBase
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
16 17 18 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 16 def comment @comment end |
#in_use ⇒ Object
Returns the value of attribute in_use.
17 18 19 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 17 def in_use @in_use end |
#login ⇒ Object
Returns the value of attribute login.
15 16 17 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 15 def login @login end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 14 def name @name end |
#package ⇒ Object
Returns the value of attribute package.
20 21 22 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 20 def package @package end |
#package_type ⇒ Object
Returns the value of attribute package_type.
21 22 23 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 21 def package_type @package_type end |
#password ⇒ Object
Returns the value of attribute password.
22 23 24 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 22 def password @password end |
#password_confirmation ⇒ Object
Returns the value of attribute password_confirmation.
23 24 25 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 23 def password_confirmation @password_confirmation end |
#public_key ⇒ Object
Returns the value of attribute public_key.
19 20 21 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 19 def public_key @public_key end |
#type ⇒ Object
Returns the value of attribute type.
18 19 20 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 18 def type @type end |
Class Method Details
.from_xml_node(node) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 112 def self.from_xml_node(node) ret = VasLscCredential.new ret.id = extract_value_from("@id", node) ret.name = extract_value_from("name", node) ret.login = extract_value_from("login", node) ret.comment = extract_value_from("comment", node) ret.in_use = extract_value_from("in_use", node).to_i > 0 ret.type = extract_value_from("type", node) ret.public_key = extract_value_from("public_key", node) ret.package = extract_value_from("package", node) ret.package_type = extract_value_from("package/@format", node) node.xpath("targets/target").each { |t| ret.target_keys << extract_value_from("@id", t) } ret end |
.get_all(options = {}) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 90 def self.get_all(={}) params = {:sort_field => 'name'} params[:lsc_credential_id] = [:id] if [:id] req = Nokogiri::XML::Builder.new { |xml| xml.get_lsc_credentials(params) } ret = [] begin resp = connection.send_receive(req.doc) resp.xpath("//lsc_credential").each { |cred| ret << from_xml_node(cred) } rescue VasExceptions::CommandException => e end ret end |
Instance Method Details
#create_or_update ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 38 def create_or_update if @id #update req = Nokogiri::XML::Builder.new { |xml| xml.modify_lsc_credential(:lsc_credential_id => @id) { xml.name { xml.text(@name) } xml.comment { xml.text(@comment) } if @comment xml.login { xml.text(@login) } xml.password { xml.text(@password) } if @password } } else #create req = Nokogiri::XML::Builder.new { |xml| xml.create_lsc_credential { xml.name { xml.text(@name) } xml.comment { xml.text(@comment) } if @comment xml.login { xml.text(@login) } xml.password { xml.text(@password) } if @password } } end begin resp = VasLscCredential.connection.send_receive(req.doc) @id = VasLscCredential.extract_value_from("create_lsc_credential_response/@id", resp) unless @id true rescue VasExceptions::CommandException => e errors[:command_failure] << e. nil end end |
#delete_record ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 73 def delete_record return unless @id req = Nokogiri::XML::Builder.new { |xml| xml.delete_lsc_credential( :lsc_credential_id => @id ) } begin VasLscCredential.connection.send_receive(req.doc) true rescue VasExceptions::CommandException errors[:command_failure] << e. nil end end |
#target_keys ⇒ Object
30 31 32 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 30 def target_keys @target_keys ||= [] end |
#targets ⇒ Object
34 35 36 |
# File 'lib/openvas-cli/vas_lsc_credential.rb', line 34 def targets @targets ||= [] end |