Class: Saml::Bindings::HTTPRedirect

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Notification

#notify

Constructor Details

#initialize(request_or_response, options = {}) ⇒ HTTPRedirect

Returns a new instance of HTTPRedirect.



43
44
45
46
47
48
# File 'lib/saml/bindings/http_redirect.rb', line 43

def initialize(request_or_response, options = {})
  @request_or_response = request_or_response
  @signature_algorithm = options[:signature_algorithm]
  @relay_state         = options[:relay_state]
  @signature           = options[:signature]
end

Instance Attribute Details

#relay_stateObject

Returns the value of attribute relay_state.



41
42
43
# File 'lib/saml/bindings/http_redirect.rb', line 41

def relay_state
  @relay_state
end

#request_or_responseObject

Returns the value of attribute request_or_response.



41
42
43
# File 'lib/saml/bindings/http_redirect.rb', line 41

def request_or_response
  @request_or_response
end

#signatureObject

Returns the value of attribute signature.



41
42
43
# File 'lib/saml/bindings/http_redirect.rb', line 41

def signature
  @signature
end

#signature_algorithmObject

Returns the value of attribute signature_algorithm.



41
42
43
# File 'lib/saml/bindings/http_redirect.rb', line 41

def signature_algorithm
  @signature_algorithm
end

Class Method Details

.create_url(request_or_response, options = {}) ⇒ Object



7
8
9
10
# File 'lib/saml/bindings/http_redirect.rb', line 7

def create_url(request_or_response, options = {})
  options[:signature_algorithm] ||= 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'
  new(request_or_response, options).create_url
end

.receive_message(http_request, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/saml/bindings/http_redirect.rb', line 12

def receive_message(http_request, options = {})
  options[:signature]           = Saml::Encoding.decode_64(http_request.params["Signature"] || "")
  options[:signature_algorithm] = http_request.params["SigAlg"]
  options[:relay_state]         = http_request.params["RelayState"]

  request_or_response = parse_request_or_response(options.delete(:type), http_request.params)

  redirect_binding = new(request_or_response, options)
  query_string     = URI.parse(http_request.url).query

  redirect_binding.verify_signature(query_string) if request_or_response.provider.authn_requests_signed?

  request_or_response.actual_destination = http_request.url
  request_or_response
end

Instance Method Details

#create_urlObject



56
57
58
# File 'lib/saml/bindings/http_redirect.rb', line 56

def create_url
  [request_or_response.destination, signed_params].join("?")
end

#verify_signature(query) ⇒ Object



50
51
52
53
54
# File 'lib/saml/bindings/http_redirect.rb', line 50

def verify_signature(query)
  unless request_or_response.provider.verify(signature_algorithm, signature, parse_signature_params(query))
    raise Saml::Errors::SignatureInvalid.new
  end
end