Class List Method List File List

# Class: SSO::Connection

Inherits:
  Object
  - Object
  - SSO::Connection
  show all
Defined in:
  /build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb

## Overview

Provides the connection details for the SSO service.

## Instance Attribute Summary (collapse)

- - (Object) password

  Returns the value of attribute password.

- - (Object) sso_url

  Returns the value of attribute sso_url.

- - (Object) username

  Returns the value of attribute username.

- - (Object) wsdl_url

  Returns the value of attribute wsdl_url.

## Instance Method Summary (collapse)

- - (Object) client

  Gets (or creates) the Savon client instance.

- - (Connection) initialize(sso_url, wsdl_url = nil) constructor

  Creates a new instance.

- - (Object) login(username, password)

  Login with the given credentials.

- - (SamlToken) request_bearer_token

  Invokes the request bearer token operation.

## Constructor Details

### - (`Connection`) initialize(sso_url, wsdl_url = nil)

Creates a new instance.

    40
    41
    42
    43
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 40

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

## Instance Attribute Details

### - (`Object`) password

Returns the value of attribute password

    37
    38
    39
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 37

    def password
      @password
    end

### - (`Object`) sso_url

Returns the value of attribute sso_url

    37
    38
    39
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 37

    def sso_url
      @sso_url
    end

### - (`Object`) username

Returns the value of attribute username

    37
    38
    39
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 37

    def username
      @username
    end

### - (`Object`) wsdl_url

Returns the value of attribute wsdl_url

    37
    38
    39
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 37

    def wsdl_url
      @wsdl_url
    end

## Instance Method Details

### - (`Object`) client

Gets (or creates) the Savon client instance.

    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 55

    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

### - (`Object`) login(username, password)

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

    48
    49
    50
    51
    52
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 48

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

### - (`SamlToken`) request_bearer_token

Invokes the request bearer token operation.

Returns:

- (`SamlToken`)

    77
    78
    79
    80
    81
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sso.rb', line 77

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