saml-kit 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/exe/saml-kit-create-self-signed-certificate +1 -1
  3. data/exe/saml-kit-decode-http-post +1 -3
  4. data/exe/saml-kit-decode-http-redirect +2 -3
  5. data/lib/saml/kit.rb +1 -14
  6. data/lib/saml/kit/assertion.rb +14 -11
  7. data/lib/saml/kit/bindings/url_builder.rb +1 -1
  8. data/lib/saml/kit/builders.rb +2 -2
  9. data/lib/saml/kit/builders/assertion.rb +3 -2
  10. data/lib/saml/kit/builders/authentication_request.rb +3 -2
  11. data/lib/saml/kit/builders/encrypted_assertion.rb +20 -0
  12. data/lib/saml/kit/builders/identity_provider_metadata.rb +4 -3
  13. data/lib/saml/kit/builders/logout_request.rb +3 -2
  14. data/lib/saml/kit/builders/logout_response.rb +3 -2
  15. data/lib/saml/kit/builders/metadata.rb +4 -3
  16. data/lib/saml/kit/builders/response.rb +14 -5
  17. data/lib/saml/kit/builders/service_provider_metadata.rb +2 -1
  18. data/lib/saml/kit/builders/templates/assertion.builder +21 -23
  19. data/lib/saml/kit/builders/templates/encrypted_assertion.builder +5 -0
  20. data/lib/saml/kit/configuration.rb +2 -2
  21. data/lib/saml/kit/document.rb +11 -1
  22. data/lib/saml/kit/metadata.rb +13 -6
  23. data/lib/saml/kit/namespaces.rb +0 -11
  24. data/lib/saml/kit/signature.rb +1 -1
  25. data/lib/saml/kit/trustable.rb +7 -1
  26. data/lib/saml/kit/version.rb +1 -1
  27. data/lib/saml/kit/xml_templatable.rb +37 -0
  28. data/saml-kit.gemspec +1 -3
  29. metadata +10 -56
  30. data/lib/saml/kit/builders/templates/certificate.builder +0 -7
  31. data/lib/saml/kit/builders/templates/nil_class.builder +0 -0
  32. data/lib/saml/kit/builders/templates/xml_encryption.builder +0 -16
  33. data/lib/saml/kit/builders/templates/xml_signature.builder +0 -20
  34. data/lib/saml/kit/builders/xml_encryption.rb +0 -20
  35. data/lib/saml/kit/builders/xml_signature.rb +0 -40
  36. data/lib/saml/kit/certificate.rb +0 -96
  37. data/lib/saml/kit/crypto.rb +0 -17
  38. data/lib/saml/kit/crypto/oaep_cipher.rb +0 -22
  39. data/lib/saml/kit/crypto/rsa_cipher.rb +0 -23
  40. data/lib/saml/kit/crypto/simple_cipher.rb +0 -38
  41. data/lib/saml/kit/crypto/unknown_cipher.rb +0 -18
  42. data/lib/saml/kit/fingerprint.rb +0 -50
  43. data/lib/saml/kit/id.rb +0 -14
  44. data/lib/saml/kit/key_pair.rb +0 -29
  45. data/lib/saml/kit/self_signed_certificate.rb +0 -28
  46. data/lib/saml/kit/signatures.rb +0 -57
  47. data/lib/saml/kit/templatable.rb +0 -67
  48. data/lib/saml/kit/template.rb +0 -33
  49. data/lib/saml/kit/xml.rb +0 -80
  50. data/lib/saml/kit/xml_decryption.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb58a002fa7488ce7c1baa15239d37f10a92d38e
4
- data.tar.gz: 83776e36bb603f5abeca6029342cc3f9bacd6ef2
3
+ metadata.gz: ea04912ee0a128c6ad73be1006827a0759698b07
4
+ data.tar.gz: 3a2c7424b611f7c60fd67d55e8df21c7339d9ae6
5
5
  SHA512:
6
- metadata.gz: a7117ae3e3516159c9ab85a9c964659b677afea39a90638146519d1f770131bc8287170cccbba3b9189ef1ce7d5a245ccaf33e11aeda40771de3d96fdeb8a965
7
- data.tar.gz: 510fc88b81a2f485e82fc6eba9146201eb69482e8166ced1659465fdace63dd9176b5887d21b010c3c812909fffe6e2f28d60a335770b3d07c85b497cf0c346e
6
+ metadata.gz: 7241a12e8e8614289205f12b238208742514e70bd66ce33e42ca7244597d62db1622de32c6ed1e968e2cc5cf9e735bbf3ab78fcd2c15f829b325e518621eb1a7
7
+ data.tar.gz: 8e280182ced754e6d2120e9c65d04233dc0ea979cbe0e74002d2e9156b4bdb8aa3030e122c21c24b6ca353b14daf83a45a261a4178ffe4cbc992cac716fca4b1
@@ -3,7 +3,7 @@ require 'saml/kit'
3
3
 
4
4
  puts "Enter Passphrase:"
5
5
  passphrase = STDIN.read.strip
6
- certificate, private_key = Saml::Kit::SelfSignedCertificate.new(passphrase).create
6
+ certificate, private_key = ::Xml::Kit::SelfSignedCertificate.new(passphrase).create
7
7
 
8
8
  puts "** BEGIN File Format **"
9
9
  print certificate
@@ -2,7 +2,5 @@
2
2
  require 'saml/kit'
3
3
 
4
4
  saml = STDIN.read
5
-
6
5
  binding = Saml::Kit::Bindings::HttpPost.new(location: '')
7
- xml = binding.deserialize('SAMLRequest' => saml).to_xml
8
- puts Nokogiri::XML(xml).to_xml(indent: 2)
6
+ puts binding.deserialize('SAMLRequest' => saml).to_xml(pretty: true)
@@ -2,6 +2,5 @@
2
2
  require 'saml/kit'
3
3
 
4
4
  saml = STDIN.read
5
- binding = Saml::Kit::HttpRedirectBinding.new(location: '')
6
- xml = binding.deserialize('SAMLRequest' => saml).to_xml
7
- puts Nokogiri::XML(xml).to_xml(indent: 2)
5
+ binding = Saml::Kit::Bindings::HttpRedirectBinding.new(location: '')
6
+ puts binding.deserialize('SAMLRequest' => saml).to_xml(pretty: true)
@@ -7,16 +7,13 @@ require "active_support/core_ext/hash/indifferent_access"
7
7
  require "active_support/core_ext/numeric/time"
8
8
  require "active_support/deprecation"
9
9
  require "active_support/duration"
10
- require "builder"
11
10
  require "logger"
12
11
  require "net/http"
13
12
  require "nokogiri"
14
13
  require "securerandom"
15
- require "tilt"
16
- require "xmldsig"
14
+ require "xml/kit"
17
15
 
18
16
  require "saml/kit/buildable"
19
- require "saml/kit/templatable"
20
17
  require "saml/kit/builders"
21
18
  require "saml/kit/namespaces"
22
19
  require "saml/kit/serializable"
@@ -30,27 +27,17 @@ require "saml/kit/document"
30
27
  require "saml/kit/assertion"
31
28
  require "saml/kit/authentication_request"
32
29
  require "saml/kit/bindings"
33
- require "saml/kit/certificate"
34
30
  require "saml/kit/configuration"
35
- require "saml/kit/crypto"
36
31
  require "saml/kit/default_registry"
37
- require "saml/kit/fingerprint"
38
- require "saml/kit/key_pair"
39
32
  require "saml/kit/logout_response"
40
33
  require "saml/kit/logout_request"
41
34
  require "saml/kit/metadata"
42
35
  require "saml/kit/composite_metadata"
43
36
  require "saml/kit/response"
44
- require "saml/kit/id"
45
37
  require "saml/kit/identity_provider_metadata"
46
38
  require "saml/kit/invalid_document"
47
- require "saml/kit/self_signed_certificate"
48
39
  require "saml/kit/service_provider_metadata"
49
40
  require "saml/kit/signature"
50
- require "saml/kit/signatures"
51
- require "saml/kit/template"
52
- require "saml/kit/xml"
53
- require "saml/kit/xml_decryption"
54
41
 
55
42
  I18n.load_path += Dir[File.expand_path("kit/locales/*.yml", File.dirname(__FILE__))]
56
43
 
@@ -72,17 +72,20 @@ module Saml
72
72
  attr_reader :configuration
73
73
 
74
74
  def assertion
75
- @assertion ||= if encrypted?
76
- decrypted = XmlDecryption.new(configuration: configuration).decrypt(@xml_hash['Response']['EncryptedAssertion'])
77
- Saml::Kit.logger.debug(decrypted)
78
- Hash.from_xml(decrypted)['Assertion']
79
- else
80
- result = @xml_hash.fetch('Response', {}).fetch('Assertion', {})
81
- return result if result.is_a?(Hash)
82
-
83
- errors[:assertion] << error_message(:must_contain_single_assertion)
84
- {}
85
- end
75
+ @assertion ||=
76
+ if encrypted?
77
+ private_keys = configuration.private_keys(use: :encryption)
78
+ decryptor = ::Xml::Kit::Decryption.new(private_keys: private_keys)
79
+ decrypted = decryptor.decrypt(@xml_hash['Response']['EncryptedAssertion'])
80
+ Saml::Kit.logger.debug(decrypted)
81
+ Hash.from_xml(decrypted)['Assertion']
82
+ else
83
+ result = @xml_hash.fetch('Response', {}).fetch('Assertion', {})
84
+ return result if result.is_a?(Hash)
85
+
86
+ errors[:assertion] << error_message(:must_contain_single_assertion)
87
+ {}
88
+ end
86
89
  end
87
90
 
88
91
  def parse_date(value)
@@ -34,7 +34,7 @@ module Saml
34
34
  to_query_string(
35
35
  saml_document.query_string_parameter => serialize(saml_document.to_xml),
36
36
  'RelayState' => relay_state,
37
- 'SigAlg' => Saml::Kit::Namespaces::SHA256,
37
+ 'SigAlg' => ::Xml::Kit::Namespaces::SHA256,
38
38
  )
39
39
  end
40
40
 
@@ -1,13 +1,13 @@
1
+ require 'saml/kit/xml_templatable'
1
2
  require 'saml/kit/builders/assertion'
2
3
  require 'saml/kit/builders/authentication_request'
4
+ require 'saml/kit/builders/encrypted_assertion'
3
5
  require 'saml/kit/builders/identity_provider_metadata'
4
6
  require 'saml/kit/builders/logout_request'
5
7
  require 'saml/kit/builders/logout_response'
6
8
  require 'saml/kit/builders/metadata'
7
9
  require 'saml/kit/builders/response'
8
10
  require 'saml/kit/builders/service_provider_metadata'
9
- require 'saml/kit/builders/xml_encryption'
10
- require 'saml/kit/builders/xml_signature'
11
11
 
12
12
  module Saml
13
13
  module Kit
@@ -1,11 +1,12 @@
1
1
  module Saml
2
2
  module Kit
3
3
  module Builders
4
+ # {include:file:lib/saml/kit/builders/templates/assertion.builder}
4
5
  class Assertion
5
- include Templatable
6
+ include XmlTemplatable
6
7
  extend Forwardable
7
8
 
8
- def_delegators :@response_builder, :encrypt, :embed_signature, :request, :issuer, :reference_id, :now, :configuration, :user, :version, :destination, :encryption_certificate
9
+ def_delegators :@response_builder, :embed_signature, :request, :issuer, :reference_id, :now, :configuration, :user, :version, :destination
9
10
 
10
11
  def initialize(response_builder)
11
12
  @response_builder = response_builder
@@ -1,16 +1,17 @@
1
1
  module Saml
2
2
  module Kit
3
3
  module Builders
4
+ # {include:file:lib/saml/kit/builders/templates/authentication_request.builder}
4
5
  # {include:file:spec/saml/builders/authentication_request_spec.rb}
5
6
  class AuthenticationRequest
6
- include Saml::Kit::Templatable
7
+ include XmlTemplatable
7
8
  attr_accessor :id, :now, :issuer, :assertion_consumer_service_url, :name_id_format, :destination
8
9
  attr_accessor :version
9
10
  attr_reader :configuration
10
11
 
11
12
  def initialize(configuration: Saml::Kit.configuration)
12
13
  @configuration = configuration
13
- @id = Id.generate
14
+ @id = ::Xml::Kit::Id.generate
14
15
  @issuer = configuration.issuer
15
16
  @name_id_format = Namespaces::PERSISTENT
16
17
  @now = Time.now.utc
@@ -0,0 +1,20 @@
1
+ module Saml
2
+ module Kit
3
+ module Builders
4
+ # {include:file:lib/saml/kit/builders/templates/encrypted_assertion.builder}
5
+ class EncryptedAssertion
6
+ include XmlTemplatable
7
+ extend Forwardable
8
+
9
+ attr_reader :assertion
10
+ def_delegators :@response_builder, :configuration, :encryption_certificate
11
+
12
+ def initialize(response_builder, assertion)
13
+ @response_builder = response_builder
14
+ @assertion = assertion
15
+ @encrypt = true
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,9 +1,10 @@
1
1
  module Saml
2
2
  module Kit
3
3
  module Builders
4
+ # {include:file:lib/saml/kit/builders/templates/identity_provider_metadata.builder}
4
5
  # {include:file:spec/saml/builders/identity_provider_metadata_spec.rb}
5
6
  class IdentityProviderMetadata
6
- include Saml::Kit::Templatable
7
+ include XmlTemplatable
7
8
  extend Forwardable
8
9
  attr_accessor :attributes, :name_id_formats
9
10
  attr_accessor :want_authn_requests_signed
@@ -16,7 +17,7 @@ module Saml
16
17
  @attributes = []
17
18
  @configuration = configuration
18
19
  @entity_id = configuration.issuer
19
- @id = Id.generate
20
+ @id = ::Xml::Kit::Id.generate
20
21
  @logout_urls = []
21
22
  @name_id_formats = [Namespaces::PERSISTENT]
22
23
  @single_sign_on_urls = []
@@ -42,7 +43,7 @@ module Saml
42
43
  def entity_descriptor_options
43
44
  {
44
45
  'xmlns': Namespaces::METADATA,
45
- 'xmlns:ds': Namespaces::XMLDSIG,
46
+ 'xmlns:ds': ::Xml::Kit::Namespaces::XMLDSIG,
46
47
  'xmlns:saml': Namespaces::ASSERTION,
47
48
  ID: id,
48
49
  entityID: entity_id,
@@ -1,9 +1,10 @@
1
1
  module Saml
2
2
  module Kit
3
3
  module Builders
4
+ # {include:file:lib/saml/kit/builders/templates/logout_request.builder}
4
5
  # {include:file:spec/saml/builders/logout_request_spec.rb}
5
6
  class LogoutRequest
6
- include Saml::Kit::Templatable
7
+ include XmlTemplatable
7
8
  attr_accessor :id, :destination, :issuer, :name_id_format, :now
8
9
  attr_accessor :version
9
10
  attr_reader :user, :configuration
@@ -11,7 +12,7 @@ module Saml
11
12
  def initialize(user, configuration: Saml::Kit.configuration)
12
13
  @configuration = configuration
13
14
  @user = user
14
- @id = "_#{SecureRandom.uuid}"
15
+ @id = ::Xml::Kit::Id.generate
15
16
  @issuer = configuration.issuer
16
17
  @name_id_format = Saml::Kit::Namespaces::PERSISTENT
17
18
  @now = Time.now.utc
@@ -1,16 +1,17 @@
1
1
  module Saml
2
2
  module Kit
3
3
  module Builders
4
+ # {include:file:lib/saml/kit/builders/templates/logout_response.builder}
4
5
  # {include:file:spec/saml/builders/logout_response_spec.rb}
5
6
  class LogoutResponse
6
- include Saml::Kit::Templatable
7
+ include XmlTemplatable
7
8
  attr_accessor :id, :issuer, :version, :status_code, :now, :destination
8
9
  attr_reader :request
9
10
  attr_reader :configuration
10
11
 
11
12
  def initialize(request, configuration: Saml::Kit.configuration)
12
13
  @configuration = configuration
13
- @id = Id.generate
14
+ @id = ::Xml::Kit::Id.generate
14
15
  @issuer = configuration.issuer
15
16
  @now = Time.now.utc
16
17
  @request = request
@@ -1,9 +1,10 @@
1
1
  module Saml
2
2
  module Kit
3
3
  module Builders
4
+ # {include:file:lib/saml/kit/builders/templates/metadata.builder}
4
5
  # {include:file:spec/saml/builders/metadata_spec.rb}
5
6
  class Metadata
6
- include Templatable
7
+ include XmlTemplatable
7
8
 
8
9
  attr_accessor :entity_id
9
10
  attr_accessor :id
@@ -13,7 +14,7 @@ module Saml
13
14
  attr_reader :configuration
14
15
 
15
16
  def initialize(configuration: Saml::Kit.configuration)
16
- @id = Id.generate
17
+ @id = ::Xml::Kit::Id.generate
17
18
  @entity_id = configuration.issuer
18
19
  @configuration = configuration
19
20
  end
@@ -39,7 +40,7 @@ module Saml
39
40
  def entity_descriptor_options
40
41
  {
41
42
  'xmlns': Namespaces::METADATA,
42
- 'xmlns:ds': Namespaces::XMLDSIG,
43
+ 'xmlns:ds': ::Xml::Kit::Namespaces::XMLDSIG,
43
44
  'xmlns:saml': Namespaces::ASSERTION,
44
45
  ID: id,
45
46
  entityID: entity_id,
@@ -1,20 +1,21 @@
1
1
  module Saml
2
2
  module Kit
3
3
  module Builders
4
+ # {include:file:lib/saml/kit/builders/templates/response.builder}
4
5
  # {include:file:spec/saml/builders/response_spec.rb}
5
6
  class Response
6
- include Templatable
7
+ include XmlTemplatable
7
8
  attr_reader :user, :request
8
9
  attr_accessor :id, :reference_id, :now
9
10
  attr_accessor :version, :status_code
10
- attr_accessor :issuer, :destination, :encrypt
11
+ attr_accessor :issuer, :destination
11
12
  attr_reader :configuration
12
13
 
13
14
  def initialize(user, request, configuration: Saml::Kit.configuration)
14
15
  @user = user
15
16
  @request = request
16
- @id = Id.generate
17
- @reference_id = Id.generate
17
+ @id = ::Xml::Kit::Id.generate
18
+ @reference_id = ::Xml::Kit::Id.generate
18
19
  @now = Time.now.utc
19
20
  @version = "2.0"
20
21
  @status_code = Namespaces::SUCCESS
@@ -37,7 +38,15 @@ module Saml
37
38
  private
38
39
 
39
40
  def assertion
40
- @assertion ||= Saml::Kit::Builders::Assertion.new(self)
41
+ @assertion ||=
42
+ begin
43
+ assertion = Saml::Kit::Builders::Assertion.new(self)
44
+ if encrypt
45
+ Saml::Kit::Builders::EncryptedAssertion.new(self, assertion)
46
+ else
47
+ assertion
48
+ end
49
+ end
41
50
  end
42
51
 
43
52
  def response_options
@@ -1,9 +1,10 @@
1
1
  module Saml
2
2
  module Kit
3
3
  module Builders
4
+ # {include:file:lib/saml/kit/builders/templates/service_provider_metadata.builder}
4
5
  # {include:file:spec/saml/builders/service_provider_metadata_spec.rb}
5
6
  class ServiceProviderMetadata
6
- include Saml::Kit::Templatable
7
+ include XmlTemplatable
7
8
  extend Forwardable
8
9
  attr_accessor :acs_urls, :logout_urls, :name_id_formats
9
10
  attr_accessor :want_assertions_signed
@@ -1,29 +1,27 @@
1
- encryption_for(xml: xml) do |xml|
2
- xml.Assertion(assertion_options) do
3
- xml.Issuer issuer
4
- signature_for(reference_id: reference_id, xml: xml)
5
- xml.Subject do
6
- xml.NameID name_id, Format: name_id_format
7
- xml.SubjectConfirmation Method: Saml::Kit::Namespaces::BEARER do
8
- xml.SubjectConfirmationData "", subject_confirmation_data_options
9
- end
1
+ xml.Assertion(assertion_options) do
2
+ xml.Issuer issuer
3
+ signature_for(reference_id: reference_id, xml: xml)
4
+ xml.Subject do
5
+ xml.NameID name_id, Format: name_id_format
6
+ xml.SubjectConfirmation Method: Saml::Kit::Namespaces::BEARER do
7
+ xml.SubjectConfirmationData "", subject_confirmation_data_options
10
8
  end
11
- xml.Conditions conditions_options do
12
- xml.AudienceRestriction do
13
- xml.Audience request.issuer
14
- end
9
+ end
10
+ xml.Conditions conditions_options do
11
+ xml.AudienceRestriction do
12
+ xml.Audience request.issuer
15
13
  end
16
- xml.AuthnStatement authn_statement_options do
17
- xml.AuthnContext do
18
- xml.AuthnContextClassRef Saml::Kit::Namespaces::PASSWORD
19
- end
14
+ end
15
+ xml.AuthnStatement authn_statement_options do
16
+ xml.AuthnContext do
17
+ xml.AuthnContextClassRef Saml::Kit::Namespaces::PASSWORD
20
18
  end
21
- if assertion_attributes.any?
22
- xml.AttributeStatement do
23
- assertion_attributes.each do |key, value|
24
- xml.Attribute Name: key, NameFormat: Saml::Kit::Namespaces::URI, FriendlyName: key do
25
- xml.AttributeValue value.to_s
26
- end
19
+ end
20
+ if assertion_attributes.any?
21
+ xml.AttributeStatement do
22
+ assertion_attributes.each do |key, value|
23
+ xml.Attribute Name: key, NameFormat: Saml::Kit::Namespaces::URI, FriendlyName: key do
24
+ xml.AttributeValue value.to_s
27
25
  end
28
26
  end
29
27
  end
@@ -0,0 +1,5 @@
1
+ xml.EncryptedAssertion xmlns: Saml::Kit::Namespaces::ASSERTION do
2
+ encryption_for(xml: xml) do |xml|
3
+ render assertion, xml: xml
4
+ end
5
+ end
@@ -53,7 +53,7 @@ module Saml
53
53
  # @param passphrase [String] the password to decrypt the private key.
54
54
  # @param use [Symbol] the type of key pair, `:signing` or `:encryption`
55
55
  def add_key_pair(certificate, private_key, passphrase: '', use: :signing)
56
- @key_pairs.push(KeyPair.new(certificate, private_key, passphrase, use.to_sym))
56
+ @key_pairs.push(::Xml::Kit::KeyPair.new(certificate, private_key, passphrase, use.to_sym))
57
57
  end
58
58
 
59
59
  # Generates a unique key pair that can be used for signing or encryption.
@@ -61,7 +61,7 @@ module Saml
61
61
  # @param use [Symbol] the type of key pair, `:signing` or `:encryption`
62
62
  # @param passphrase [String] the private key passphrase to use.
63
63
  def generate_key_pair_for(use:, passphrase: SecureRandom.uuid)
64
- certificate, private_key = SelfSignedCertificate.new(passphrase).create
64
+ certificate, private_key = ::Xml::Kit::SelfSignedCertificate.new(passphrase).create
65
65
  add_key_pair(certificate, private_key, passphrase: passphrase, use: use)
66
66
  end
67
67
 
@@ -2,6 +2,13 @@ module Saml
2
2
  module Kit
3
3
  class Document
4
4
  PROTOCOL_XSD = File.expand_path("./xsd/saml-schema-protocol-2.0.xsd", File.dirname(__FILE__)).freeze
5
+ NAMESPACES = {
6
+ "NameFormat": ::Saml::Kit::Namespaces::ATTR_SPLAT,
7
+ "ds": ::Xml::Kit::Namespaces::XMLDSIG,
8
+ "md": ::Saml::Kit::Namespaces::METADATA,
9
+ "saml": ::Saml::Kit::Namespaces::ASSERTION,
10
+ "samlp": ::Saml::Kit::Namespaces::PROTOCOL,
11
+ }.freeze
5
12
  include ActiveModel::Validations
6
13
  include XsdValidatable
7
14
  include Translatable
@@ -79,12 +86,15 @@ module Saml
79
86
  # @param xml [String] the raw xml string.
80
87
  # @param configuration [Saml::Kit::Configuration] the configuration to use for unpacking the document.
81
88
  def to_saml_document(xml, configuration: Saml::Kit.configuration)
89
+ xml_document = ::Xml::Kit::Document.new(xml, namespaces: {
90
+ "samlp": ::Saml::Kit::Namespaces::PROTOCOL
91
+ })
82
92
  constructor = {
83
93
  "AuthnRequest" => Saml::Kit::AuthenticationRequest,
84
94
  "LogoutRequest" => Saml::Kit::LogoutRequest,
85
95
  "LogoutResponse" => Saml::Kit::LogoutResponse,
86
96
  "Response" => Saml::Kit::Response,
87
- }[Saml::Kit::Xml.new(xml).find_by(XPATH).name] || InvalidDocument
97
+ }[xml_document.find_by(XPATH).name] || InvalidDocument
88
98
  constructor.new(xml, configuration: configuration)
89
99
  rescue => error
90
100
  Saml::Kit.logger.error(error)