class SamlIdp::ResponseBuilder
Attributes
assertion_and_signature[RW]
issuer_uri[RW]
response_id[RW]
saml_acs_url[RW]
saml_request_id[RW]
Public Class Methods
new(response_id, issuer_uri, saml_acs_url, saml_request_id, assertion_and_signature)
click to toggle source
# File lib/saml_idp/response_builder.rb, line 10 def initialize(response_id, issuer_uri, saml_acs_url, saml_request_id, assertion_and_signature) self.response_id = response_id self.issuer_uri = issuer_uri self.saml_acs_url = saml_acs_url self.saml_request_id = saml_request_id self.assertion_and_signature = assertion_and_signature end
Public Instance Methods
encoded()
click to toggle source
# File lib/saml_idp/response_builder.rb, line 18 def encoded @encoded ||= encode end
raw()
click to toggle source
# File lib/saml_idp/response_builder.rb, line 22 def raw build end
Private Instance Methods
build()
click to toggle source
# File lib/saml_idp/response_builder.rb, line 31 def build resp_options = {} resp_options[:ID] = response_id_string resp_options[:Version] = "2.0" resp_options[:IssueInstant] = now_iso resp_options[:Destination] = saml_acs_url resp_options[:Consent] = Saml::XML::Namespaces::Consents::UNSPECIFIED resp_options[:InResponseTo] = saml_request_id unless saml_request_id.nil? resp_options["xmlns:samlp"] = Saml::XML::Namespaces::PROTOCOL builder = Builder::XmlMarkup.new builder.tag! "samlp:Response", resp_options do |response| response.Issuer issuer_uri, xmlns: Saml::XML::Namespaces::ASSERTION response.tag! "samlp:Status" do |status| status.tag! "samlp:StatusCode", Value: Saml::XML::Namespaces::Statuses::SUCCESS end response << assertion_and_signature end end
encode()
click to toggle source
# File lib/saml_idp/response_builder.rb, line 26 def encode Base64.strict_encode64(raw) end
now_iso()
click to toggle source
# File lib/saml_idp/response_builder.rb, line 57 def now_iso Time.now.utc.iso8601 end
response_id_string()
click to toggle source
# File lib/saml_idp/response_builder.rb, line 52 def response_id_string "_#{response_id}" end