Sha256: 8cffb4df44fab4b823c8e3513e4b585637a5e00f4ce1c59d6893ba975ab9accc

Contents?: true

Size: 1.84 KB

Versions: 49

Compression:

Stored size: 1.84 KB

Contents

module Saml
  module Bindings
    class HTTPArtifact
      include Saml::Notification

      class << self
        # @param [Saml::ArtifactResponse] artifact_response
        def create_response_xml(artifact_response)
          notify('create_response', Saml::Util.sign_xml(artifact_response, :soap))
        end

        def create_response(artifact_response)
          {xml: create_response_xml(artifact_response), content_type: 'text/xml'}
        end

        def create_url(location, artifact, options = {})
          uri   = URI.parse(location)
          query = [uri.query, "SAMLart=#{CGI.escape(artifact.to_s)}"]

          query << "RelayState=#{CGI.escape(options[:relay_state])}" if options[:relay_state]

          uri.query = query.compact.join("&")
          uri.to_s
        end

        def receive_message(request)
          raw_xml          = notify('receive_message', request.body.dup.read)
          artifact_resolve = Saml::ArtifactResolve.parse(raw_xml, single: true)

          Saml::Util.verify_xml(artifact_resolve, raw_xml)
        end

        def resolve(request, location, additional_headers = {}, proxy = {})
          artifact         = request.params["SAMLart"]
          artifact_resolve = Saml::ArtifactResolve.new(artifact: artifact, destination: location)

          message = notify('create_post', Saml::Util.sign_xml(artifact_resolve, :soap))
          response = Saml::Util.post(location, message, additional_headers, proxy)

          if response.code == "200"
            notify('receive_response', response.body)
            artifact_response          = Saml::ArtifactResponse.parse(response.body, single: true)
            verified_artifact_response = Saml::Util.verify_xml(artifact_response, response.body)

            verified_artifact_response.message if artifact_response.success?
          end
        end
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
libsaml-3.1.0 lib/saml/bindings/http_artifact.rb
libsaml-3.0.9 lib/saml/bindings/http_artifact.rb
libsaml-2.24.3 lib/saml/bindings/http_artifact.rb
libsaml-2.24.2 lib/saml/bindings/http_artifact.rb
libsaml-3.0.8 lib/saml/bindings/http_artifact.rb
libsaml-3.0.7 lib/saml/bindings/http_artifact.rb
libsaml-3.0.6 lib/saml/bindings/http_artifact.rb
libsaml-3.0.5 lib/saml/bindings/http_artifact.rb
libsaml-3.0.4 lib/saml/bindings/http_artifact.rb
libsaml-3.0.3 lib/saml/bindings/http_artifact.rb
libsaml-3.0.2 lib/saml/bindings/http_artifact.rb
libsaml-3.0.1 lib/saml/bindings/http_artifact.rb
libsaml-2.24.1 lib/saml/bindings/http_artifact.rb
libsaml-2.23.2 lib/saml/bindings/http_artifact.rb
libsaml-2.23.1 lib/saml/bindings/http_artifact.rb
libsaml-2.22.2 lib/saml/bindings/http_artifact.rb
libsaml-2.22.1 lib/saml/bindings/http_artifact.rb
libsaml-2.22.0 lib/saml/bindings/http_artifact.rb
libsaml-2.21.3 lib/saml/bindings/http_artifact.rb
libsaml-2.21.2 lib/saml/bindings/http_artifact.rb