Commit 5509b79
Changed files (2)
lib
saml
kit
core_ext
lib/saml/kit/core_ext/metadata.rb
@@ -1,28 +1,37 @@
module Saml
module Kit
class Metadata
+ TABLE = {
+ 'Entity Id' => ->(x) { x.entity_id },
+ 'Type' => ->(x) { x.name },
+ 'Valid' => ->(x) { x.valid? },
+ 'Name Id Formats' => ->(x) { x.name_id_formats.inspect },
+ 'Organization' => ->(x) { x.organization_name },
+ 'Url' => ->(x) { x.organization_url },
+ 'Contact' => ->(x) { x.contact_person_company },
+ }.freeze
+
+ SERVICES = %w[
+ SingleSignOnService
+ SingleLogoutService
+ AssertionConsumerService
+ ].freeze
+
def build_table(table = [])
- table.push(['Entity Id', entity_id])
- table.push(['Type', name])
- table.push(['Valid', valid?])
- table.push(['Name Id Formats', name_id_formats.inspect])
- table.push(['Organization', organization_name])
- table.push(['Url', organization_url])
- table.push(['Contact', contact_person_company])
- %w[
- SingleSignOnService
- SingleLogoutService
- AssertionConsumerService
- ].each do |type|
- services(type).each do |service|
- table.push([type, [service.location, service.binding]])
- end
- end
+ TABLE.each { |key, callable| table.push([key, callable.call(self)]) }
+ build_services_table(table)
certificates.each do |certificate|
table.push(['', certificate.x509.to_text])
end
signature.build_table(table)
- table
+ end
+
+ def build_services_table(table)
+ SERVICES.each do |type|
+ services(type).each do |service|
+ table.push([type, [service.location, service.binding]])
+ end
+ end
end
end
end
lib/saml/kit/core_ext/signature.rb
@@ -1,16 +1,21 @@
module Saml
module Kit
class Signature
+ TABLE = {
+ 'Digest Value' => ->(x) { x.digest_value },
+ 'Expected Digest Value' => ->(x) { x.expected_digest_value },
+ 'Digest Method' => ->(x) { x.digest_method },
+ 'Signature Value' => ->(x) { x.truncate(signature_value) },
+ 'Signature Method' => ->(x) { x.signature_method },
+ 'Canonicalization Method' => ->(x) { x.canonicalization_method },
+ }.freeze
+
def build_table(table = [])
return table unless present?
- table.push(['Digest Value', digest_value])
- table.push(['Expected Digest Value', expected_digest_value])
- table.push(['Digest Method', digest_method])
- table.push(['Signature Value', truncate(signature_value)])
- table.push(['Signature Method', signature_method])
- table.push(['Canonicalization Method', canonicalization_method])
+ TABLE.each do |key, callable|
+ table.push([key, callable.call(self)])
+ end
table.push(['', certificate.x509.to_text])
- table
end
private