Class: ADAL::CacheDriver
- Inherits:
-
Object
- Object
- ADAL::CacheDriver
- Includes:
- Logging, RequestParameters
- Defined in:
- lib/adal/cache_driver.rb
Overview
Performs logical operations on the TokenCache in the context of one token request.
Constant Summary collapse
Constants included from RequestParameters
RequestParameters::AAD_API_VERSION, RequestParameters::ASSERTION, RequestParameters::CLIENT_ASSERTION, RequestParameters::CLIENT_ASSERTION_TYPE, RequestParameters::CLIENT_ID, RequestParameters::CLIENT_REQUEST_ID, RequestParameters::CLIENT_RETURN_CLIENT_REQUEST_ID, RequestParameters::CLIENT_SECRET, RequestParameters::CODE, RequestParameters::FORM_POST, RequestParameters::GRANT_TYPE, RequestParameters::PASSWORD, RequestParameters::REDIRECT_URI, RequestParameters::REFRESH_TOKEN, RequestParameters::RESOURCE, RequestParameters::SCOPE, RequestParameters::UNIQUE_ID, RequestParameters::USERNAME, RequestParameters::USER_INFO
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::DEFAULT_LOG_OUTPUT
Instance Method Summary collapse
-
#add(token_response) ⇒ Object
Checks if a TokenResponse is successful and if so adds it to the token cache for future retrieval.
-
#find(query = {}) ⇒ Object
Searches the cache for a token matching a specific query of fields.
-
#initialize(authority, client, token_cache = NoopCache.new, expiration_buffer_sec = 0) ⇒ CacheDriver
constructor
Constructs a CacheDriver to interact with a token cache.
Methods included from Logging
Constructor Details
#initialize(authority, client, token_cache = NoopCache.new, expiration_buffer_sec = 0) ⇒ CacheDriver
Constructs a CacheDriver to interact with a token cache.
54 55 56 57 58 59 60 |
# File 'lib/adal/cache_driver.rb', line 54 def initialize( , client, token_cache = NoopCache.new, expiration_buffer_sec = 0) @authority = @client = client @expiration_buffer_sec = expiration_buffer_sec @token_cache = token_cache end |
Instance Method Details
#add(token_response) ⇒ Object
Checks if a TokenResponse is successful and if so adds it to the token cache for future retrieval.
69 70 71 72 73 74 75 |
# File 'lib/adal/cache_driver.rb', line 69 def add(token_response) return unless token_response.instance_of? SuccessResponse logger.verbose('Adding successful TokenResponse to cache.') entry = CachedTokenResponse.new(@client, @authority, token_response) update_refresh_tokens(entry) if entry.mrrt? @token_cache.add(entry) end |
#find(query = {}) ⇒ Object
Searches the cache for a token matching a specific query of fields.
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/adal/cache_driver.rb', line 83 def find(query = {}) query = query.map { |k, v| [FIELDS[k], v] if FIELDS[k] }.compact.to_h resource = query.delete(RESOURCE) matches = validate( find_all_cached_entries( query.reverse_merge( authority: @authority, client_id: @client.client_id)) ) resource_specific(matches, resource) || refresh_mrrt(matches, resource) end |