Class: KeycloakApiRails::PublicKeyCachedResolver::RealmCache
- Inherits:
-
Object
- Object
- KeycloakApiRails::PublicKeyCachedResolver::RealmCache
- Defined in:
- lib/keycloak-api-rails/public_key_cached_resolver.rb
Instance Attribute Summary collapse
-
#cached_public_key_retrieved_at ⇒ Object
readonly
Returns the value of attribute cached_public_key_retrieved_at.
Instance Method Summary collapse
- #find_public_keys(public_key_cache_ttl, logger) ⇒ Object
-
#initialize(http_client, realm_id) ⇒ RealmCache
constructor
A new instance of RealmCache.
Constructor Details
#initialize(http_client, realm_id) ⇒ RealmCache
Returns a new instance of RealmCache.
10 11 12 13 14 15 16 17 |
# File 'lib/keycloak-api-rails/public_key_cached_resolver.rb', line 10 def initialize(http_client, realm_id) @resolver = PublicKeyResolver.new(http_client, realm_id) @cached_public_keys = nil @cached_public_key_retrieved_at = nil @last_refresh_failure_at = nil @last_refresh_error = nil @mutex = Mutex.new end |
Instance Attribute Details
#cached_public_key_retrieved_at ⇒ Object (readonly)
Returns the value of attribute cached_public_key_retrieved_at.
8 9 10 |
# File 'lib/keycloak-api-rails/public_key_cached_resolver.rb', line 8 def cached_public_key_retrieved_at @cached_public_key_retrieved_at end |
Instance Method Details
#find_public_keys(public_key_cache_ttl, logger) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/keycloak-api-rails/public_key_cached_resolver.rb', line 19 def find_public_keys(public_key_cache_ttl, logger) @mutex.synchronize do raise @last_refresh_error if refresh_recently_failed_without_any_cache? refresh_public_keys(logger) if public_keys_are_outdated?(public_key_cache_ttl) @cached_public_keys end end |