Module: JWT::JWA::SigningAlgorithm
- Included in:
- Ecdsa, Eddsa, Hmac, HmacRbNaCl, HmacRbNaClFixed, None, Ps, Rsa, Unsupported, Wrapper
- Defined in:
- lib/jwt/jwa/signing_algorithm.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#alg ⇒ Object
readonly
Returns the value of attribute alg.
Class Method Summary collapse
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.
17 18 19 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 17 def alg @alg end |
Class Method Details
.included(klass) ⇒ Object
12 13 14 15 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 12 def self.included(klass) klass.extend(ClassMethods) klass.include(JWT::JWA::Compat) end |
Instance Method Details
#header ⇒ Object
23 24 25 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 23 def header(*) { 'alg' => alg } end |
#raise_sign_error!(message) ⇒ Object
39 40 41 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 39 def raise_sign_error!() raise(EncodeError.new().tap { |e| e.set_backtrace(caller(1)) }) end |
#raise_verify_error!(message) ⇒ Object
35 36 37 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 35 def raise_verify_error!() raise(DecodeError.new().tap { |e| e.set_backtrace(caller(1)) }) end |
#sign ⇒ Object
27 28 29 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 27 def sign(*) raise_sign_error!('Algorithm implementation is missing the sign method') end |
#valid_alg?(alg_to_check) ⇒ Boolean
19 20 21 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 19 def valid_alg?(alg_to_check) alg&.casecmp(alg_to_check)&.zero? == true end |
#verify ⇒ Object
31 32 33 |
# File 'lib/jwt/jwa/signing_algorithm.rb', line 31 def verify(*) raise_verify_error!('Algorithm implementation is missing the verify method') end |