Class: JWT::Algos::AlgoWrapper
- Inherits:
-
Object
- Object
- JWT::Algos::AlgoWrapper
- Defined in:
- lib/jwt/algos/algo_wrapper.rb
Instance Attribute Summary collapse
-
#alg ⇒ Object
readonly
Returns the value of attribute alg.
-
#cls ⇒ Object
readonly
Returns the value of attribute cls.
Instance Method Summary collapse
-
#initialize(alg, cls) ⇒ AlgoWrapper
constructor
A new instance of AlgoWrapper.
- #sign(data:, signing_key:) ⇒ Object
- #valid_alg?(alg_to_check) ⇒ Boolean
- #verify(data:, signature:, verification_key:) ⇒ Object
Constructor Details
#initialize(alg, cls) ⇒ AlgoWrapper
Returns a new instance of AlgoWrapper.
8 9 10 11 |
# File 'lib/jwt/algos/algo_wrapper.rb', line 8 def initialize(alg, cls) @alg = alg @cls = cls end |
Instance Attribute Details
#alg ⇒ Object (readonly)
Returns the value of attribute alg.
6 7 8 |
# File 'lib/jwt/algos/algo_wrapper.rb', line 6 def alg @alg end |
#cls ⇒ Object (readonly)
Returns the value of attribute cls.
6 7 8 |
# File 'lib/jwt/algos/algo_wrapper.rb', line 6 def cls @cls end |
Instance Method Details
#sign(data:, signing_key:) ⇒ Object
17 18 19 |
# File 'lib/jwt/algos/algo_wrapper.rb', line 17 def sign(data:, signing_key:) cls.sign(alg, data, signing_key) end |
#valid_alg?(alg_to_check) ⇒ Boolean
13 14 15 |
# File 'lib/jwt/algos/algo_wrapper.rb', line 13 def valid_alg?(alg_to_check) alg&.casecmp(alg_to_check)&.zero? == true end |
#verify(data:, signature:, verification_key:) ⇒ Object
21 22 23 |
# File 'lib/jwt/algos/algo_wrapper.rb', line 21 def verify(data:, signature:, verification_key:) cls.verify(alg, verification_key, data, signature) end |