Class: Saml::Kit::Bindings::UrlBuilder

Inherits:
Object
  • Object
show all
Includes:
Serializable
Defined in:
lib/saml/kit/bindings/url_builder.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Serializable

#decode, #deflate, #encode, #escape, #inflate, #unescape

Constructor Details

#initialize(configuration: Saml::Kit.configuration) ⇒ UrlBuilder

Returns a new instance of UrlBuilder.



11
12
13
# File 'lib/saml/kit/bindings/url_builder.rb', line 11

def initialize(configuration: Saml::Kit.configuration)
  @configuration = configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



9
10
11
# File 'lib/saml/kit/bindings/url_builder.rb', line 9

def configuration
  @configuration
end

Instance Method Details

#build(saml_document, relay_state: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/saml/kit/bindings/url_builder.rb', line 15

def build(saml_document, relay_state: nil)
  if configuration.sign?
    payload = canonicalize(saml_document, relay_state)
    "#{saml_document.destination}?#{payload}&Signature=#{signature_for(payload)}"
  else
    payload = to_query_string(
      saml_document.query_string_parameter => serialize(saml_document.to_xml),
      'RelayState' => relay_state
    )
    "#{saml_document.destination}?#{payload}"
  end
end