Commit 2b94e4f

mo <mo@mokhan.ca>
2017-12-13 16:55:30
move encryption to assertion.builder.
1 parent 3b8bbde
Changed files (3)
lib/saml/kit/builders/templates/assertion.builder
@@ -1,27 +1,29 @@
-xml.Assertion(assertion_options) do
-  xml.Issuer issuer
-  signature_for(reference_id: reference_id, xml: xml) unless encrypt
-  xml.Subject do
-    xml.NameID name_id, Format: name_id_format
-    xml.SubjectConfirmation Method: Saml::Kit::Namespaces::BEARER do
-      xml.SubjectConfirmationData "", subject_confirmation_data_options
+encryption_for(xml: xml) do |xml|
+  xml.Assertion(assertion_options) do
+    xml.Issuer issuer
+    signature_for(reference_id: reference_id, xml: xml) unless encrypt
+    xml.Subject do
+      xml.NameID name_id, Format: name_id_format
+      xml.SubjectConfirmation Method: Saml::Kit::Namespaces::BEARER do
+        xml.SubjectConfirmationData "", subject_confirmation_data_options
+      end
     end
-  end
-  xml.Conditions conditions_options do
-    xml.AudienceRestriction do
-      xml.Audience request.issuer
+    xml.Conditions conditions_options do
+      xml.AudienceRestriction do
+        xml.Audience request.issuer
+      end
     end
-  end
-  xml.AuthnStatement authn_statement_options do
-    xml.AuthnContext do
-      xml.AuthnContextClassRef Saml::Kit::Namespaces::PASSWORD
+    xml.AuthnStatement authn_statement_options do
+      xml.AuthnContext do
+        xml.AuthnContextClassRef Saml::Kit::Namespaces::PASSWORD
+      end
     end
-  end
-  if assertion_attributes.any?
-    xml.AttributeStatement do
-      assertion_attributes.each do |key, value|
-        xml.Attribute Name: key, NameFormat: Saml::Kit::Namespaces::URI, FriendlyName: key do
-          xml.AttributeValue value.to_s
+    if assertion_attributes.any?
+      xml.AttributeStatement do
+        assertion_attributes.each do |key, value|
+          xml.Attribute Name: key, NameFormat: Saml::Kit::Namespaces::URI, FriendlyName: key do
+            xml.AttributeValue value.to_s
+          end
         end
       end
     end
lib/saml/kit/builders/templates/response.builder
@@ -5,7 +5,5 @@ xml.Response response_options do
   xml.Status do
     xml.StatusCode Value: status_code
   end
-  encryption_for(xml: xml) do |xml|
-    render assertion, xml: xml
-  end
+  render assertion, xml: xml
 end
lib/saml/kit/builders/assertion.rb
@@ -5,7 +5,7 @@ module Saml
         include Templatable
         extend Forwardable
 
-        def_delegators :@response_builder, :encrypt, :sign, :request, :issuer, :reference_id, :now, :configuration, :user, :version, :destination
+        def_delegators :@response_builder, :encrypt, :sign, :request, :issuer, :reference_id, :now, :configuration, :user, :version, :destination, :encryption_certificate
 
         def initialize(response_builder)
           @response_builder = response_builder