Module: JWT::JWA::SigningAlgorithm
Overview
Base functionality for signing algorithms
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#alg ⇒ Object
readonly
Returns the value of attribute alg.
Instance Method Summary collapse
- #header ⇒ Object
- #raise_sign_error!(message) ⇒ Object
- #raise_verify_error!(message) ⇒ Object
- #sign ⇒ Object
- #valid_alg?(alg_to_check) ⇒ Boolean
- #verify ⇒ Object
Instance Attribute Details
#alg ⇒ Object (readonly)
Returns the value of attribute alg.
19 20 21 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 19 def alg @alg end |
Instance Method Details
#header ⇒ Object
25 26 27 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 25 def header(*) { 'alg' => alg } end |
#raise_sign_error!(message) ⇒ Object
41 42 43 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 41 def raise_sign_error!() raise(EncodeError.new().tap { |e| e.set_backtrace(caller(1)) }) end |
#raise_verify_error!(message) ⇒ Object
37 38 39 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 37 def raise_verify_error!() raise(DecodeError.new().tap { |e| e.set_backtrace(caller(1)) }) end |
#sign ⇒ Object
29 30 31 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 29 def sign(*) raise_sign_error!('Algorithm implementation is missing the sign method') end |
#valid_alg?(alg_to_check) ⇒ Boolean
21 22 23 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 21 def valid_alg?(alg_to_check) alg&.casecmp(alg_to_check)&.zero? == true end |
#verify ⇒ Object
33 34 35 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 33 def verify(*) raise_verify_error!('Algorithm implementation is missing the verify method') end |