Class: RHC::Rest::WWWAuth::OAuth2

Inherits:
Object
  • Object
show all
Includes:
HTTPClient::Util
Defined in:
lib/rhc/rest/httpclient.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOAuth2

Returns a new instance of OAuth2.



61
62
63
64
65
66
# File 'lib/rhc/rest/httpclient.rb', line 61

def initialize
  @cred = nil
  @auth = {}
  @set = false
  @scheme = "Bearer"
end

Instance Attribute Details

#schemeObject (readonly)

Returns the value of attribute scheme.



59
60
61
# File 'lib/rhc/rest/httpclient.rb', line 59

def scheme
  @scheme
end

Instance Method Details

#challenge(uri, param_str = nil) ⇒ Object



96
97
98
# File 'lib/rhc/rest/httpclient.rb', line 96

def challenge(uri, param_str = nil)
  false
end

#get(req) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/rhc/rest/httpclient.rb', line 88

def get(req)
  target_uri = req.header.request_uri
  return @cred if @cred
  hash_find_value(@auth) { |uri, cred|
    uri_part_of(target_uri, uri)
  }
end

#reset_challengeObject



68
69
# File 'lib/rhc/rest/httpclient.rb', line 68

def reset_challenge
end

#set(uri, user, password) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/rhc/rest/httpclient.rb', line 71

def set(uri, user, password)
  @set = true
  if uri.nil?
    @cred = password
  else
    @auth[urify(uri)] = password
  end
end

#set?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/rhc/rest/httpclient.rb', line 84

def set?
  @set == true
end

#set_token(uri, token) ⇒ Object



80
81
82
# File 'lib/rhc/rest/httpclient.rb', line 80

def set_token(uri, token)
  set(uri, nil, token)
end