Class: Nexpose::Email
- Inherits:
-
Object
- Object
- Nexpose::Email
- Defined in:
- lib/nexpose/common.rb
Overview
Configuration structure for e-mail notification.
The send_as and send_to_acl_as attributes are optional, but one of them is required for sending reports via e-mail. The send_as attribute is required for sending e-mails to users who are not on the report access list. The send_to_acl attribute is required for sending e-mails to report access list members.
E-mails and attachments are sent via the Internet in clear text and are not encrypted. If you do not set a valid value for either attribute, the application will save the report but not send it via e-mail. If you set a valid value for the send_as attribute but not for the send_to_acl_as attribute, the application will send the report via e-mail to non-access-list members only. If you set a valid value for the send_to_acl_as attribute, the application will send the report via e-mail to access-list members only. If you set a valid value for both attributes, the application will send reports via e-mail to access-list members and non-members.
Instance Attribute Summary collapse
-
#recipients ⇒ Object
Array of report recipients (i.e., not already on the report access list).
-
#send_as ⇒ Object
Send as file attachment or zipped file to individuals who are not members of the report access list.
-
#send_to_acl_as ⇒ Object
Send to users on the report access list.
-
#send_to_owner_as ⇒ Object
Format to send to users on the report access list.
-
#sender ⇒ Object
Sender that e-mail will be attributed to.
-
#smtp_relay_server ⇒ Object
SMTP relay server.
-
#to_all_authorized ⇒ Object
Send to all the authorized users of sites, groups, and assets.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(to_all_authorized, send_to_owner_as, send_to_acl_as, send_as) ⇒ Email
constructor
A new instance of Email.
- #to_xml ⇒ Object
Constructor Details
#initialize(to_all_authorized, send_to_owner_as, send_to_acl_as, send_as) ⇒ Email
Returns a new instance of Email.
48 49 50 51 52 53 54 55 |
# File 'lib/nexpose/common.rb', line 48 def initialize(, send_to_owner_as, send_to_acl_as, send_as) @to_all_authorized = @send_to_owner_as = send_to_owner_as @send_to_acl_as = send_to_acl_as @send_as = send_as @recipients = [] end |
Instance Attribute Details
#recipients ⇒ Object
Array of report recipients (i.e., not already on the report access list).
46 47 48 |
# File 'lib/nexpose/common.rb', line 46 def recipients @recipients end |
#send_as ⇒ Object
Send as file attachment or zipped file to individuals who are not members of the report access list. One of: file|zip
33 34 35 |
# File 'lib/nexpose/common.rb', line 33 def send_as @send_as end |
#send_to_acl_as ⇒ Object
Send to users on the report access list.
37 38 39 |
# File 'lib/nexpose/common.rb', line 37 def send_to_acl_as @send_to_acl_as end |
#send_to_owner_as ⇒ Object
Format to send to users on the report access list. One of: file|zip|url
39 40 41 |
# File 'lib/nexpose/common.rb', line 39 def send_to_owner_as @send_to_owner_as end |
#sender ⇒ Object
Sender that e-mail will be attributed to.
42 43 44 |
# File 'lib/nexpose/common.rb', line 42 def sender @sender end |
#smtp_relay_server ⇒ Object
SMTP relay server.
44 45 46 |
# File 'lib/nexpose/common.rb', line 44 def smtp_relay_server @smtp_relay_server end |
#to_all_authorized ⇒ Object
Send to all the authorized users of sites, groups, and assets.
35 36 37 |
# File 'lib/nexpose/common.rb', line 35 def @to_all_authorized end |
Class Method Details
.parse(xml) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/nexpose/common.rb', line 76 def self.parse(xml) xml.elements.each('//Email') do |email| config = Email.new(email.attributes['toAllAuthorized'] == '1', email.attributes['sendToOwnerAs'], email.attributes['sendToAclAs'], email.attributes['sendAs']) xml.elements.each('//Sender') do |sender| config.sender = sender.text end xml.elements.each('//SmtpRelayServer') do |server| config.smtp_relay_server = server.text end xml.elements.each('//Recipient') do |recipient| config.recipients << recipient.text end return config end nil end |
Instance Method Details
#to_xml ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/nexpose/common.rb', line 57 def to_xml xml = '<Email' xml << %( toAllAuthorized='#{@toAllAuthorized ? 1 : 0}') xml << %( sendToOwnerAs='#{@send_to_owner_as}') if @send_to_owner_as xml << %( sendToAclAs='#{@send_to_acl_as}') if @send_to_acl_as xml << %( sendAs='#{@send_as}') if @send_as xml << '>' xml << %(<Sender>#{@sender}</Sender>) if @sender xml << %(<SmtpRelayServer>#{@smtp_relay_server}</SmtpRelayServer>) if @smtp_relay_server if @recipients xml << '<Recipients>' @recipients.each do |recipient| xml << %(<Recipient>#{recipient}</Recipient>) end xml << '</Recipients>' end xml << '</Email>' end |