Class: Saml::Bindings::HTTPArtifact
- Inherits:
-
Object
- Object
- Saml::Bindings::HTTPArtifact
- Includes:
- Notification
- Defined in:
- lib/saml/bindings/http_artifact.rb
Class Method Summary collapse
- .create_response(artifact_response) ⇒ Object
- .create_response_xml(artifact_response) ⇒ Object
- .create_url(location, artifact, options = {}) ⇒ Object
- .receive_message(request) ⇒ Object
- .resolve(request, location) ⇒ Object
Methods included from Notification
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
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, = {}) uri = URI.parse(location) query = [uri.query, "SAMLart=#{CGI.escape(artifact.to_s)}"] query << "RelayState=#{CGI.escape([:relay_state])}" if [: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 (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 |