class Saml::Bindings::HTTPArtifact

Public Class Methods

create_response(artifact_response) click to toggle source
# File lib/saml/bindings/http_artifact.rb, line 12
def create_response(artifact_response)
  {xml: create_response_xml(artifact_response), content_type: 'text/xml'}
end
create_response_xml(artifact_response) click to toggle source

@param [Saml::ArtifactResponse] artifact_response

# File lib/saml/bindings/http_artifact.rb, line 8
def create_response_xml(artifact_response)
  notify('create_response', Saml::Util.sign_xml(artifact_response, :soap))
end
create_url(location, artifact, options = {}) click to toggle source
# File lib/saml/bindings/http_artifact.rb, line 16
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
receive_message(request) click to toggle source
# File lib/saml/bindings/http_artifact.rb, line 26
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
resolve(request, location, additional_headers = {}, proxy = {}) click to toggle source
# File lib/saml/bindings/http_artifact.rb, line 33
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