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.



33
34
35
36
# File 'lib/sso.rb', line 33

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.



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

def password
  @password
end

#sso_urlObject

Returns the value of attribute sso_url.



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

def sso_url
  @sso_url
end

#usernameObject

Returns the value of attribute username.



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

def username
  @username
end

#wsdl_urlObject

Returns the value of attribute wsdl_url.



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

def wsdl_url
  @wsdl_url
end

Instance Method Details

#clientObject

Gets (or creates) the Savon client instance.



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

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.



41
42
43
44
45
# File 'lib/sso.rb', line 41

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

#request_bearer_tokenSamlToken

Invokes the request bearer token operation.

Returns:



70
71
72
73
74
# File 'lib/sso.rb', line 70

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