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
Recipients will be in form of email address.
-
#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.
50 51 52 53 54 55 56 |
# File 'lib/nexpose/common.rb', line 50 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
Recipients will be in form of email address.
- Array<String>
-
E-mail addresses of additional report recipients (i.e., not already on the report access list).
48 49 50 |
# File 'lib/nexpose/common.rb', line 48 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.
- String
-
Attachment format, ‘file’ | ‘zip’.
30 31 32 |
# File 'lib/nexpose/common.rb', line 30 def send_as @send_as end |
#send_to_acl_as ⇒ Object
Send to users on the report access list.
- String
-
Attachment format ‘file’ | ‘zip’
36 37 38 |
# File 'lib/nexpose/common.rb', line 36 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.
- String
-
Attachment format ‘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.
- String
-
an email address
42 43 44 |
# File 'lib/nexpose/common.rb', line 42 def sender @sender end |
#smtp_relay_server ⇒ Object
SMTP relay server.
- String
-
the IP address, host name or FQDN of the SMTP server.
45 46 47 |
# File 'lib/nexpose/common.rb', line 45 def smtp_relay_server @smtp_relay_server end |
#to_all_authorized ⇒ Object
Send to all the authorized users of sites, groups, and assets.
- Fixnum
-
1 | 0
33 34 35 |
# File 'lib/nexpose/common.rb', line 33 def @to_all_authorized end |
Class Method Details
.parse(xml) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/nexpose/common.rb', line 77 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
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/nexpose/common.rb', line 58 def to_xml xml = '<Email' xml << %( toAllAuthorized='#{@to_all_authorized ? 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 |