Commit 4c28988
Changed files (3)
lib
saml
kit
builders
spec
saml
kit
builders
lib/saml/kit/builders/encrypted_assertion.rb
@@ -10,13 +10,18 @@ module Saml
extend Forwardable
attr_reader :assertion
+ attr_accessor :destination
def_delegators :@response_builder,
:configuration,
:encryption_certificate
def_delegators :@assertion,
:default_name_id_format,
- :default_name_id_format=
+ :default_name_id_format=,
+ :destination=,
+ :embed_signature,
+ :issuer=,
+ :now=
def initialize(response_builder, assertion)
@response_builder = response_builder
lib/saml/kit/builders/response.rb
@@ -52,6 +52,17 @@ module Saml
end
end
+ def encrypt=(value)
+ super(value)
+ return if @assertion.nil?
+
+ if value
+ @assertion = EncryptedAssertion.new(self, assertion) if assertion.is_a?(Assertion)
+ elsif assertion.is_a?(EncryptedAssertion)
+ @assertion = assertion.assertion if assertion.is_a?(EncryptedAssertion)
+ end
+ end
+
def destination=(value)
@destination = value
assertion.destination = value
spec/saml/kit/builders/response_spec.rb
@@ -76,6 +76,8 @@ RSpec.describe Saml::Kit::Builders::Response do
allow(Saml::Kit.configuration).to receive(:entity_id).and_return(issuer)
subject.destination = assertion_consumer_service_url
subject.encrypt = false
+ subject.encrypt = true
+ subject.encrypt = false
hash = Hash.from_xml(subject.to_xml)
expect(hash['Response']['ID']).to be_present