main
1# frozen_string_literal: true
2
3module Saml
4 module Kit
5 # This module is responsible for
6 # generating converting templates to xml.
7 module XmlTemplatable
8 TEMPLATES_DIR = Pathname.new(File.join(__dir__, '../builders/templates/'))
9 include ::Xml::Kit::Templatable
10
11 def template_path
12 @template_path ||= TEMPLATES_DIR.join(template_name)
13 end
14
15 def template_name
16 "#{self.class.name.split('::').last.underscore}.builder"
17 end
18
19 # Returns true if an embedded signature is requested and at least one
20 # signing certificate is available via the configuration.
21 def sign?
22 return configuration.sign? if embed_signature.nil?
23
24 (embed_signature && configuration.sign?) ||
25 (embed_signature && signing_key_pair.present?)
26 end
27
28 def digest_method
29 configuration.digest_method
30 end
31
32 def signature_method
33 configuration.signature_method
34 end
35
36 def signing_key_pair
37 @signing_key_pair || configuration.key_pairs(use: :signing).last
38 end
39 end
40 end
41end