Class: SharedSecretTokenProvider

Inherits:
TokenProvider show all
Defined in:
lib/acs/shared_secret_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(issuer_name, issuer_secret, proxy = nil) ⇒ SharedSecretTokenProvider

  • issuer_name: Issuer name provided when the service is created

  • issuer_key: Management key provided when the service is created

  • proxy: Hash containing http_proxy_server, http_proxy_port and optional http_porxy_username, http_proxy_password



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

def initialize(issuer_name, issuer_secret, proxy = nil)
  set_http_web_proxy(proxy) if proxy
  @issuer_name = issuer_name
  @issuer_secret = issuer_secret
end

Instance Attribute Details

#issuer_nameObject (readonly)

Returns the value of attribute issuer_name.



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

def issuer_name
  @issuer_name
end

#issuer_secretObject (readonly)

Returns the value of attribute issuer_secret.



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

def issuer_secret
  @issuer_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/shared_secret_token_provider.rb', line 44

def token(request_uri, applies_to)
  computed_simple_web_token_string = TokenProvider.compute_simple_web_token(@issuer_name, @issuer_secret)
  simple_auth_parameter_name = TokenConstants.simple_auth_simple_web_token
  params = ''
  params = TokenConstants.simple_auth_applies_to + "=" + CGI::escape(applies_to)
  params << TokenConstants.url_parameter_separator
  params << simple_auth_parameter_name + "=" + CGI::escape(computed_simple_web_token_string)
  issue_token(request_uri, params)
end