Module: Saml::Kit::Templatable

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#embed_signature ⇒ Object

Returns the value of attribute embed_signature.



4
5
6
# File 'lib/saml/kit/templatable.rb', line 4

def embed_signature
  @embed_signature
end

Instance Method Details

#encrypt? ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/saml/kit/templatable.rb', line 40

def encrypt?
  encrypt && encryption_certificate
end

#encryption_for(xml:) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/saml/kit/templatable.rb', line 28

def encryption_for(xml:)
  if encrypt?
    temp = ::Builder::XmlMarkup.new
    yield temp
    signed_xml = signatures.complete(temp.target!)
    xml_encryption = Saml::Kit::Builders::XmlEncryption.new(signed_xml, encryption_certificate.public_key)
    render(xml_encryption, xml: xml)
  else
    yield xml
  end
end

#render(model, options) ⇒ Object



44
45
46
# File 'lib/saml/kit/templatable.rb', line 44

def render(model, options)
  Saml::Kit::Template.new(model).to_xml(options)
end

#sign=(value) ⇒ Object



6
7
8
9
# File 'lib/saml/kit/templatable.rb', line 6

def sign=(value)
  Saml::Kit.deprecate("sign= is deprecated. Use embed_signature= instead")
  self.embed_signature = value
end

#sign? ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/saml/kit/templatable.rb', line 20

def sign?
  embed_signature.nil? ? configuration.sign? : embed_signature && configuration.sign?
end

#signature_for(reference_id:, xml:) ⇒ Object



15
16
17
18
# File 'lib/saml/kit/templatable.rb', line 15

def signature_for(reference_id:, xml:)
  return unless sign?
  render(signatures.build(reference_id), xml: xml)
end

#signatures ⇒ Object



24
25
26
# File 'lib/saml/kit/templatable.rb', line 24

def signatures
  @signatures ||= Saml::Kit::Signatures.new(configuration: configuration)
end

#to_xml(xml: ::Builder::XmlMarkup.new) ⇒ Object



11
12
13
# File 'lib/saml/kit/templatable.rb', line 11

def to_xml(xml: ::Builder::XmlMarkup.new)
  signatures.complete(render(self, xml: xml))
end