Class: SimpleApiAuthTokenProvider

Inherits:
TokenProvider show all
Defined in:
lib/acs/simple_api_auth_token_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TokenProvider

compute_simple_web_token, #issue_token, token_hmc_key

Methods included from HTTPProxy

#set_http_web_proxy

Methods included from DotNetServices::HTTPRequests

#delete, #get, #post, #proxy, #put

Constructor Details

#initialize(wrap_name, wrap_password, proxy = nil) ⇒ SimpleApiAuthTokenProvider

  • wrap_name: Scope name provided when the service is created

  • wrap_password: ‘Client Getting Started Issuer key’ provided when the service is created

  • proxy: Hash containing http_web_proxy_server, http_web_proxy_port and optional http_web_proxy_username, http_web_proxy_password



35
36
37
38
39
# File 'lib/acs/simple_api_auth_token_provider.rb', line 35

def initialize(wrap_name, wrap_password, proxy = nil)
  @wrap_name = wrap_name
  @wrap_password = wrap_password
  set_http_web_proxy(proxy) if proxy
end

Instance Attribute Details

#wrap_nameObject (readonly)

Returns the value of attribute wrap_name.



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

def wrap_name
  @wrap_name
end

#wrap_secretObject (readonly)

Returns the value of attribute wrap_secret.



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

def wrap_secret
  @wrap_secret
end

Instance Method Details

#token(request_uri, applies_to) ⇒ Object

Constructs params to sent along with the token reuqest uri and calls issue_token

  • request_uri: Request url

  • applies_to: URL the token applies to



44
45
46
47
48
49
50
51
52
# File 'lib/acs/simple_api_auth_token_provider.rb', line 44

def token(request_uri, applies_to)
  params = ''
  params = TokenConstants.simple_auth_applies_to + "=" + CGI::escape(applies_to)
  params << TokenConstants.url_parameter_separator
  params << TokenConstants.simple_auth_name + "=" + CGI::escape(@wrap_name)
  params << TokenConstants.url_parameter_separator
  params << TokenConstants.simple_auth_password + "=" + CGI::escape(@wrap_password)
  issue_token(request_uri, params)
end