Commit ec7749a
Changed files (4)
lib
lib/saml/kit/authentication_request.rb
@@ -5,7 +5,6 @@ module Saml
validates_presence_of :acs_url, if: :login?
validate :must_have_valid_signature
validate :must_be_registered
- validate :must_match_xsd
def initialize(xml)
super(xml, name: "AuthnRequest")
@@ -55,10 +54,6 @@ module Saml
end
end
- def must_match_xsd
- matches_xsd?(PROTOCOL_XSD)
- end
-
def login?
request?
end
lib/saml/kit/document.rb
@@ -6,6 +6,7 @@ module Saml
include ActiveModel::Validations
include Trustable
validates_presence_of :content
+ validate :must_match_xsd
attr_reader :content, :name
@@ -43,20 +44,28 @@ module Saml
to_xml
end
- def self.to_saml_document(xml)
- hash = Hash.from_xml(xml)
- if hash['Response'].present?
- Response.new(xml)
- elsif hash['LogoutResponse'].present?
- LogoutResponse.new(xml)
- elsif hash['AuthnRequest'].present?
- AuthenticationRequest.new(xml)
- elsif hash['LogoutRequest'].present?
- LogoutRequest.new(xml)
+ class << self
+ def to_saml_document(xml)
+ hash = Hash.from_xml(xml)
+ if hash['Response'].present?
+ Response.new(xml)
+ elsif hash['LogoutResponse'].present?
+ LogoutResponse.new(xml)
+ elsif hash['AuthnRequest'].present?
+ AuthenticationRequest.new(xml)
+ elsif hash['LogoutRequest'].present?
+ LogoutRequest.new(xml)
+ end
+ rescue => error
+ Saml::Kit.logger.error(error)
+ InvalidDocument.new(xml)
end
- rescue => error
- Saml::Kit.logger.error(error)
- InvalidDocument.new(xml)
+ end
+
+ private
+
+ def must_match_xsd
+ matches_xsd?(PROTOCOL_XSD)
end
end
end
lib/saml/kit/logout_request.rb
@@ -5,7 +5,6 @@ module Saml
validates_presence_of :single_logout_service, if: :logout?
validate :must_have_valid_signature
validate :must_be_registered
- validate :must_match_xsd
def initialize(xml)
super(xml, name: "LogoutRequest")
@@ -51,10 +50,6 @@ module Saml
errors[:fingerprint] << error_message(:invalid_fingerprint)
end
- def must_match_xsd
- matches_xsd?(PROTOCOL_XSD)
- end
-
def logout?
request?
end
lib/saml/kit/response.rb
@@ -7,7 +7,6 @@ module Saml
validates_presence_of :id
validate :must_have_valid_signature
validate :must_be_registered
- validate :must_match_xsd
validate :must_be_valid_version
validates_inclusion_of :status_code, in: [Namespaces::SUCCESS]
@@ -70,10 +69,6 @@ module Saml
errors[:base] << error_message(:unregistered)
end
- def must_match_xsd
- matches_xsd?(PROTOCOL_XSD)
- end
-
def must_be_valid_version
return unless login?
return if "2.0" == version