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.13.1 lib/saml/bindings/http_artifact.rb
libsaml-3.13.0 lib/saml/bindings/http_artifact.rb
libsaml-3.12.0 lib/saml/bindings/http_artifact.rb
libsaml-3.11.0 lib/saml/bindings/http_artifact.rb
libsaml-3.10.0 lib/saml/bindings/http_artifact.rb
libsaml-3.9.3 lib/saml/bindings/http_artifact.rb
libsaml-3.9.2 lib/saml/bindings/http_artifact.rb
libsaml-3.9.1 lib/saml/bindings/http_artifact.rb
libsaml-3.9.0 lib/saml/bindings/http_artifact.rb
libsaml-3.8.0 lib/saml/bindings/http_artifact.rb
libsaml-3.7.0 lib/saml/bindings/http_artifact.rb
libsaml-3.6.0 lib/saml/bindings/http_artifact.rb
libsaml-3.5.0 lib/saml/bindings/http_artifact.rb
libsaml-3.4.0 lib/saml/bindings/http_artifact.rb
libsaml-3.3.0 lib/saml/bindings/http_artifact.rb
libsaml-3.2.3 lib/saml/bindings/http_artifact.rb
libsaml-3.2.2 lib/saml/bindings/http_artifact.rb
libsaml-3.2.1 lib/saml/bindings/http_artifact.rb
libsaml-3.1.2 lib/saml/bindings/http_artifact.rb
libsaml-3.1.1 lib/saml/bindings/http_artifact.rb