Class: HealthCards::Verifier
- Inherits:
-
Object
- Object
- HealthCards::Verifier
- Extended by:
- Verification
- Includes:
- Verification
- Defined in:
- lib/health_cards/verifier.rb
Overview
Verifiers can validate HealthCards using public keys
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#resolve_keys ⇒ Object
Returns the value of attribute resolve_keys.
Class Method Summary collapse
-
.verify(verifiable) ⇒ Boolean
Verify a Payload.
Instance Method Summary collapse
-
#add_keys(key) ⇒ Object
Add a key to use when verifying.
-
#initialize(keys: nil, resolve_keys: true) ⇒ Verifier
constructor
Create a new Verifier.
-
#remove_keys(key) ⇒ Object
Remove a key to use when verifying.
- #resolve_keys? ⇒ Boolean
-
#verify(verifiable) ⇒ Boolean
Verify a Payload.
Methods included from Verification
resolve_key, verify_using_key_set
Constructor Details
#initialize(keys: nil, resolve_keys: true) ⇒ Verifier
Create a new Verifier
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/health_cards/verifier.rb', line 29 def initialize(keys: nil, resolve_keys: true) @keys = case keys when KeySet keys when Key KeySet.new(keys) else KeySet.new end self.resolve_keys = resolve_keys end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
9 10 11 |
# File 'lib/health_cards/verifier.rb', line 9 def keys @keys end |
#resolve_keys ⇒ Object
Returns the value of attribute resolve_keys.
10 11 12 |
# File 'lib/health_cards/verifier.rb', line 10 def resolve_keys @resolve_keys end |
Class Method Details
.verify(verifiable) ⇒ Boolean
Verify a Payload
This method always uses key resolution and does not depend on any cached keys
21 22 23 |
# File 'lib/health_cards/verifier.rb', line 21 def self.verify(verifiable) verify_using_key_set(verifiable) end |
Instance Method Details
#add_keys(key) ⇒ Object
Add a key to use when verifying
45 46 47 |
# File 'lib/health_cards/verifier.rb', line 45 def add_keys(key) @keys.add_keys(key) end |
#remove_keys(key) ⇒ Object
Remove a key to use when verifying
52 53 54 |
# File 'lib/health_cards/verifier.rb', line 52 def remove_keys(key) @keys.remove_keys(key) end |
#resolve_keys? ⇒ Boolean
64 65 66 |
# File 'lib/health_cards/verifier.rb', line 64 def resolve_keys? resolve_keys end |
#verify(verifiable) ⇒ Boolean
Verify a Payload
60 61 62 |
# File 'lib/health_cards/verifier.rb', line 60 def verify(verifiable) verify_using_key_set(verifiable, keys, resolve_keys: resolve_keys?) end |