Commit 37ec473

mo <mo@mokhan.ca>
2017-12-11 23:26:51
extract render method.
1 parent f7d08b2
lib/saml/kit/builders/templates/authentication_request.builder
@@ -1,3 +1,4 @@
+xml.instruct!
 xml.tag!('samlp:AuthnRequest', request_options) do
   xml.tag!('saml:Issuer', issuer)
   signature_for(reference_id: id, xml: xml)
lib/saml/kit/builders/templates/logout_response.builder
@@ -1,3 +1,4 @@
+xml.instruct!
 xml.LogoutResponse logout_response_options do
   xml.Issuer(issuer, xmlns: Saml::Kit::Namespaces::ASSERTION)
   signature_for(reference_id: id, xml: xml)
lib/saml/kit/builders/templates/response.builder
@@ -1,3 +1,4 @@
+xml.instruct!
 xml.Response response_options do
   xml.Issuer(issuer, xmlns: Saml::Kit::Namespaces::ASSERTION)
   signature_for(reference_id: id, xml: xml)
@@ -5,6 +6,6 @@ xml.Response response_options do
     xml.StatusCode Value: status_code
   end
   encryption_for(xml: xml) do |xml|
-    Saml::Kit::Template.new(assertion).to_xml(xml: xml)
+    render assertion, xml: xml
   end
 end
lib/saml/kit/builders/templates/xml_signature.builder
@@ -14,7 +14,7 @@ xml.Signature "xmlns" => Saml::Kit::Namespaces::XMLDSIG do
   xml.SignatureValue ""
   xml.KeyInfo do
     xml.X509Data do
-      xml.X509Certificate stripped_signing_certificate
+      xml.X509Certificate x509_certificate
     end
   end
 end
lib/saml/kit/builders/xml_signature.rb
@@ -19,13 +19,13 @@ module Saml
 
         attr_reader :sign, :configuration
         attr_reader :reference_id
-        attr_reader :stripped_signing_certificate
+        attr_reader :x509_certificate
 
         def initialize(reference_id, configuration:, sign: true)
           @configuration = configuration
           @reference_id = reference_id
           @sign = sign
-          @stripped_signing_certificate = configuration.stripped_signing_certificate
+          @x509_certificate = configuration.stripped_signing_certificate
         end
 
         def signature_method
lib/saml/kit/templatable.rb
@@ -2,12 +2,12 @@ module Saml
   module Kit
     module Templatable
       def to_xml(xml: ::Builder::XmlMarkup.new)
-        signatures.complete(Template.new(self).to_xml(xml: xml))
+        signatures.complete(render(self, xml: xml))
       end
 
       def signature_for(reference_id:, xml:)
         return unless sign
-        Template.new(signatures.build(reference_id)).to_xml(xml: xml)
+        render(signatures.build(reference_id), xml: xml)
       end
 
       def signatures
@@ -19,11 +19,15 @@ module Saml
           temp = ::Builder::XmlMarkup.new
           yield temp
           xml_encryption = Saml::Kit::Builders::XmlEncryption.new(temp.target!, encryption_certificate.public_key)
-          Template.new(xml_encryption).to_xml(xml: xml)
+          render(xml_encryption, xml: xml)
         else
           yield xml
         end
       end
+
+      def render(model, options)
+        Saml::Kit::Template.new(model).to_xml(options)
+      end
     end
   end
 end