Class: Saml::Bindings::HTTPArtifact

Inherits:
Object
  • Object
show all
Includes:
Notification
Defined in:
lib/saml/bindings/http_artifact.rb

Class Method Summary collapse

Methods included from Notification

#notify

Class Method Details

.create_response(artifact_response) ⇒ Object



12
13
14
# 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) ⇒ Object

Parameters:



8
9
10
# 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 = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# 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) ⇒ Object



26
27
28
29
30
31
# 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) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/saml/bindings/http_artifact.rb', line 33

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

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

  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.response if artifact_response.success?
  end
end