Class: PaypalAPI::WebhookVerifier::CertsCache Private
- Inherits:
-
Object
- Object
- PaypalAPI::WebhookVerifier::CertsCache
- Defined in:
- lib/paypal-api/webhook_verifier/certs_cache.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Stores certifiactes in-memory.
New values are added to this in-memory cache and application cache. When fetching value it firstly looks to the memory cache and then to the app cache.
Instance Attribute Summary collapse
-
#app_cache ⇒ Object
readonly
private
Current application cache.
-
#storage ⇒ Object
readonly
private
Hash storage of certificate public keys.
Instance Method Summary collapse
-
#fetch(key, &block) ⇒ OpenSSL::PKey::PKey
private
Fetches value from cache.
-
#initialize(app_cache) ⇒ CertsCache
constructor
private
Initializes certificates cache.
Constructor Details
#initialize(app_cache) ⇒ CertsCache
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes certificates cache
28 29 30 31 |
# File 'lib/paypal-api/webhook_verifier/certs_cache.rb', line 28 def initialize(app_cache) @app_cache = app_cache || NullCache @storage = {} end |
Instance Attribute Details
#app_cache ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Current application cache
16 17 18 |
# File 'lib/paypal-api/webhook_verifier/certs_cache.rb', line 16 def app_cache @app_cache end |
#storage ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Hash storage of certificate public keys
20 21 22 |
# File 'lib/paypal-api/webhook_verifier/certs_cache.rb', line 20 def storage @storage end |
Instance Method Details
#fetch(key, &block) ⇒ OpenSSL::PKey::PKey
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Fetches value from cache
39 40 41 42 43 44 45 46 47 |
# File 'lib/paypal-api/webhook_verifier/certs_cache.rb', line 39 def fetch(key, &block) openssl_pub_key = read(key) return openssl_pub_key if openssl_pub_key cert_string = app_cache.fetch(key, &block) cert = OpenSSL::X509::Certificate.new(cert_string) write(key, cert.public_key) end |