main
1# frozen_string_literal: true
2
3module Saml
4 module Kit
5 class Signature
6 TABLE = {
7 'Digest Value' => ->(x) { x.digest_value },
8 'Expected Digest Value' => ->(x) { x.expected_digest_value },
9 'Digest Method' => ->(x) { x.digest_method },
10 'Signature Value' => ->(x) { x.truncate(x.signature_value) },
11 'Signature Method' => ->(x) { x.signature_method },
12 'Canonicalization Method' => ->(x) { x.canonicalization_method },
13 }.freeze
14
15 def build_table(table = [])
16 return table unless present?
17 TABLE.each do |key, callable|
18 table.push([key, callable.call(self)])
19 end
20 table.push(['', certificate.x509.to_text]) if certificate
21 end
22
23 def truncate(text, max: 50)
24 text.length >= max ? "#{text[0..max]}..." : text
25 end
26 end
27 end
28end