Class: Saml::Bindings::HTTPArtifact
- Inherits:
-
Object
- Object
- Saml::Bindings::HTTPArtifact
- 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
Class Method Details
.create_response(artifact_response) ⇒ Object
11 12 13 |
# File 'lib/saml/bindings/http_artifact.rb', line 11 def create_response(artifact_response) {xml: create_response_xml(artifact_response), content_type: 'text/xml'} end |
.create_response_xml(artifact_response) ⇒ Object
7 8 9 |
# File 'lib/saml/bindings/http_artifact.rb', line 7 def create_response_xml(artifact_response) Saml::Util.sign_xml(artifact_response, :soap) end |
.create_url(location, artifact, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/saml/bindings/http_artifact.rb', line 15 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
25 26 27 28 29 30 |
# File 'lib/saml/bindings/http_artifact.rb', line 25 def (request) raw_xml = 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
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/saml/bindings/http_artifact.rb', line 32 def resolve(request, location) artifact = request.params["SAMLart"] artifact_resolve = Saml::ArtifactResolve.new(artifact: artifact, destination: location) response = Saml::Util.post(location, Saml::Util.sign_xml(artifact_resolve, :soap)) if response.code == "200" 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 |