Commit 3389355
Changed files (11)
lib
saml
kit
spec
saml
builders
xml-kit
lib
spec
lib/saml/kit/assertion.rb
@@ -72,17 +72,19 @@ module Saml
attr_reader :configuration
def assertion
- @assertion ||= if encrypted?
- decrypted = XmlDecryption.new(configuration: configuration).decrypt(@xml_hash['Response']['EncryptedAssertion'])
- Saml::Kit.logger.debug(decrypted)
- Hash.from_xml(decrypted)['Assertion']
- else
- result = @xml_hash.fetch('Response', {}).fetch('Assertion', {})
- return result if result.is_a?(Hash)
-
- errors[:assertion] << error_message(:must_contain_single_assertion)
- {}
- end
+ @assertion ||=
+ if encrypted?
+ decryptor = ::Xml::Kit::XmlDecryption.new(configuration: configuration)
+ decrypted = decryptor.decrypt(@xml_hash['Response']['EncryptedAssertion'])
+ Saml::Kit.logger.debug(decrypted)
+ Hash.from_xml(decrypted)['Assertion']
+ else
+ result = @xml_hash.fetch('Response', {}).fetch('Assertion', {})
+ return result if result.is_a?(Hash)
+
+ errors[:assertion] << error_message(:must_contain_single_assertion)
+ {}
+ end
end
def parse_date(value)
lib/saml/kit.rb
@@ -33,7 +33,6 @@ require "saml/kit/authentication_request"
require "saml/kit/bindings"
require "saml/kit/certificate"
require "saml/kit/configuration"
-require "saml/kit/crypto"
require "saml/kit/default_registry"
require "saml/kit/fingerprint"
require "saml/kit/key_pair"
@@ -51,7 +50,6 @@ require "saml/kit/signature"
require "saml/kit/signatures"
require "saml/kit/template"
require "saml/kit/xml"
-require "saml/kit/xml_decryption"
I18n.load_path += Dir[File.expand_path("kit/locales/*.yml", File.dirname(__FILE__))]
spec/saml/builders/response_spec.rb
@@ -93,7 +93,7 @@ RSpec.describe Saml::Kit::Builders::Response do
result = Hash.from_xml(subject.to_xml)
expect(result['Response']['EncryptedAssertion']).to be_present
encrypted_assertion = result['Response']['EncryptedAssertion']
- decrypted_assertion = Saml::Kit::XmlDecryption.new(configuration: configuration).decrypt(encrypted_assertion)
+ decrypted_assertion = Xml::Kit::XmlDecryption.new(configuration: configuration).decrypt(encrypted_assertion)
decrypted_hash = Hash.from_xml(decrypted_assertion)
expect(decrypted_hash['Assertion']).to be_present
expect(decrypted_hash['Assertion']['Issuer']).to be_present
lib/saml/kit/crypto/oaep_cipher.rb → xml-kit/lib/xml/kit/crypto/oaep_cipher.rb
@@ -1,4 +1,4 @@
-module Saml
+module Xml
module Kit
module Crypto
class OaepCipher
lib/saml/kit/crypto/rsa_cipher.rb → xml-kit/lib/xml/kit/crypto/rsa_cipher.rb
@@ -1,4 +1,4 @@
-module Saml
+module Xml
module Kit
module Crypto
class RsaCipher
lib/saml/kit/crypto/simple_cipher.rb → xml-kit/lib/xml/kit/crypto/simple_cipher.rb
@@ -1,4 +1,4 @@
-module Saml
+module Xml
module Kit
module Crypto
class SimpleCipher
lib/saml/kit/crypto/unknown_cipher.rb → xml-kit/lib/xml/kit/crypto/unknown_cipher.rb
@@ -1,4 +1,4 @@
-module Saml
+module Xml
module Kit
module Crypto
class UnknownCipher
lib/saml/kit/crypto.rb → xml-kit/lib/xml/kit/crypto.rb
@@ -1,9 +1,9 @@
-require 'saml/kit/crypto/oaep_cipher'
-require 'saml/kit/crypto/rsa_cipher'
-require 'saml/kit/crypto/simple_cipher'
-require 'saml/kit/crypto/unknown_cipher'
+require 'xml/kit/crypto/oaep_cipher'
+require 'xml/kit/crypto/rsa_cipher'
+require 'xml/kit/crypto/simple_cipher'
+require 'xml/kit/crypto/unknown_cipher'
-module Saml
+module Xml
module Kit
module Crypto
DECRYPTORS = [ SimpleCipher, RsaCipher, OaepCipher, UnknownCipher ]
lib/saml/kit/xml_decryption.rb → xml-kit/lib/xml/kit/xml_decryption.rb
@@ -1,4 +1,4 @@
-module Saml
+module Xml
module Kit
# {include:file:spec/saml/xml_decryption_spec.rb}
class XmlDecryption
xml-kit/lib/xml/kit.rb
@@ -1,7 +1,9 @@
require "xml/kit/version"
+require "xml/kit/crypto"
+require "xml/kit/xml_decryption"
+
module Xml
module Kit
- # Your code goes here...
end
end
spec/saml/xml_decryption_spec.rb → xml-kit/spec/xml/xml_decryption_spec.rb
@@ -1,4 +1,4 @@
-RSpec.describe Saml::Kit::XmlDecryption do
+RSpec.describe Xml::Kit::XmlDecryption do
describe "#decrypt" do
let(:secret) { FFaker::Movie.title }
let(:password) { FFaker::Movie.title }