Class: SSO::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/sso.rb

Overview

Provides the connection details for the SSO service.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sso_url, wsdl_url = nil) ⇒ Connection

Creates a new instance.



31
32
33
34
# File 'lib/sso.rb', line 31

def initialize(sso_url, wsdl_url = nil)
  self.sso_url = sso_url
  self.wsdl_url = wsdl_url || "#{sso_url}?wsdl"
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



28
29
30
# File 'lib/sso.rb', line 28

def password
  @password
end

#sso_urlObject

Returns the value of attribute sso_url.



28
29
30
# File 'lib/sso.rb', line 28

def sso_url
  @sso_url
end

#usernameObject

Returns the value of attribute username.



28
29
30
# File 'lib/sso.rb', line 28

def username
  @username
end

#wsdl_urlObject

Returns the value of attribute wsdl_url.



28
29
30
# File 'lib/sso.rb', line 28

def wsdl_url
  @wsdl_url
end

Instance Method Details

#clientObject

Gets (or creates) the Savon client instance.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sso.rb', line 46

def client
  # construct and init the client proxy
  @client ||= Savon.client do |globals|
    # see: http://savonrb.com/version2/globals.html
    globals.wsdl wsdl_url
    globals.endpoint sso_url

    globals.strip_namespaces false
    globals.env_namespace :S

    # set like this so https connection does not fail
    # TODO: find an acceptable solution for production
    globals.ssl_verify_mode :none

    # dev/debug settings
    # globals.pretty_print_xml ENV['DEBUG_SOAP']
    # globals.log ENV['DEBUG_SOAP']
  end
end

#login(username, password) ⇒ Object

Login with the given credentials. Note: this does not invoke a login action, but rather stores the credentials for use later.



39
40
41
42
43
# File 'lib/sso.rb', line 39

def (username, password)
  self.username = username
  self.password = password
  self # enable builder pattern
end

#request_bearer_tokenSamlToken

Invokes the request bearer token operation.

Returns:



68
69
70
71
72
# File 'lib/sso.rb', line 68

def request_bearer_token
  rst = RequestSecurityToken.new(client, username, password)
  rst.invoke
  rst.saml_token
end