Story #107192666 - refactor to add stricter inclusion rules

reformatted block, white space changes, indent for surounding if any?
pull up find_all? if *_allowed then check if allowed.any?
This commit is contained in:
Matt Farnsworth 2015-11-13 19:06:12 +02:00
parent ad3a2a6adb
commit e7c2444161

View file

@ -60,39 +60,44 @@ xml.epp_head do
end
end
xml.extension do
def tag_key_data(xml, key)
xml.tag!('secDNS:keyData') do
xml.tag!('secDNS:flags', key.flags)
xml.tag!('secDNS:protocol', key.protocol)
xml.tag!('secDNS:alg', key.alg)
xml.tag!('secDNS:pubKey', key.public_key)
end
end
if @domain.dnskeys.any?
ds_data = Setting.ds_data_allowed ? @domain.dnskeys.find_all { |key| key.ds_digest.present? } : []
key_data = Setting.key_data_allowed ? @domain.dnskeys.find_all { |key| key.ds_digest.blank? } : []
def tag_ds_data(xml, key)
xml.tag!('secDNS:dsData') do
xml.tag!('secDNS:keyTag', key.ds_key_tag)
xml.tag!('secDNS:alg', key.ds_alg)
xml.tag!('secDNS:digestType', key.ds_digest_type)
xml.tag!('secDNS:digest', key.ds_digest)
tag_key_data(xml, key) if key.public_key.present?
end
end
xml.tag!('secDNS:infData', 'xmlns:secDNS' => 'urn:ietf:params:xml:ns:secDNS-1.1') do
if Setting.ds_data_allowed
(@domain.dnskeys.find_all { |key| key.ds_digest.present? }).sort.each do |key|
tag_ds_data(xml, key)
end
else
(@domain.dnskeys.find_all { |key| key.ds_digest.blank? }).sort.each do |key|
tag_key_data(xml, key)
# is there any reason to include <extension> without <secDNS:infData>
xml.extension do
def tag_key_data(xml, key)
xml.tag!('secDNS:keyData') do
xml.tag!('secDNS:flags', key.flags)
xml.tag!('secDNS:protocol', key.protocol)
xml.tag!('secDNS:alg', key.alg)
xml.tag!('secDNS:pubKey', key.public_key)
end
end
end
end if @domain.dnskeys.any? && (Setting.ds_data_allowed ? @domain.dnskeys.any? { |key| key.ds_digest.present? } : Setting.key_data_allowed)
def tag_ds_data(xml, key)
xml.tag!('secDNS:dsData') do
xml.tag!('secDNS:keyTag', key.ds_key_tag)
xml.tag!('secDNS:alg', key.ds_alg)
xml.tag!('secDNS:digestType', key.ds_digest_type)
xml.tag!('secDNS:digest', key.ds_digest)
tag_key_data(xml, key) if key.public_key.present?
end
end
xml.tag!('secDNS:infData', 'xmlns:secDNS' => 'urn:ietf:params:xml:ns:secDNS-1.1') do
if Setting.ds_data_allowed
ds_data.sort.each do |key|
tag_ds_data(xml, key)
end
else
key_data.sort.each do |key|
tag_key_data(xml, key)
end
end
end
end if key_data.present? || ds_data.present?
end
render('epp/shared/trID', builder: xml)
end
end