summaryrefslogtreecommitdiff
path: root/lib/saml/kit/core_ext/document.rb
blob: 4cb5fd0fadb99d5c00b962bcb99b0a269205ff6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module Saml
  module Kit
    class Document
      TABLE = {
        'ID' => ->(x) { x.id },
        'Issuer' => ->(x) { x.issuer },
        'Version' => ->(x) { x.version },
        'Issue Instant' => ->(x) { x.issue_instant.iso8601 },
        'Type' => ->(x) { x.name },
        'Valid' => ->(x) { x.valid? },
        'Signed?' => ->(x) { x.signed? },
        'Trusted?' => ->(x) { x.trusted? },
      }.freeze

      def build_table(table = [])
        TABLE.each do |key, callable|
          table.push([key, callable.call(self)])
        end
        signature.build_table(table)
      end
    end
  end
end