Class: RHC::Rest::WWWAuth::OAuth2
- Includes:
- HTTPClient::Util
- Defined in:
- lib/rhc/rest/httpclient.rb
Instance Attribute Summary collapse
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
Instance Method Summary collapse
- #challenge(uri, param_str = nil) ⇒ Object
- #get(req) ⇒ Object
-
#initialize ⇒ OAuth2
constructor
A new instance of OAuth2.
- #reset_challenge ⇒ Object
- #set(uri, user, password) ⇒ Object
- #set? ⇒ Boolean
- #set_token(uri, token) ⇒ Object
Constructor Details
#initialize ⇒ OAuth2
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
#scheme ⇒ Object (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_challenge ⇒ Object
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
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 |