main
 1# frozen_string_literal: true
 2
 3module Saml
 4  module Kit
 5    class Metadata
 6      TABLE = {
 7        'Entity Id' => ->(x) { x.entity_id },
 8        'Type' => ->(x) { x.name },
 9        'Valid' => ->(x) { x.valid? },
10        'Name Id Formats' => ->(x) { x.name_id_formats.inspect },
11        'Organization' => ->(x) { x.organization_name },
12        'Url' => ->(x) { x.organization_url },
13        'Contact' => ->(x) { x.contact_person_company },
14      }.freeze
15
16      SERVICES = %w[
17        SingleSignOnService
18        SingleLogoutService
19        AssertionConsumerService
20      ].freeze
21
22      def build_table(table = [])
23        TABLE.each { |key, callable| table.push([key, callable.call(self)]) }
24        build_services_table(table)
25        certificates.each do |certificate|
26          table.push(['', certificate.x509.to_text])
27        end
28        signature.build_table(table)
29      end
30
31      def build_services_table(table)
32        SERVICES.each do |type|
33          services(type).each do |service|
34            table.push([type, [service.location, service.binding]])
35          end
36        end
37      end
38    end
39  end
40end