Module: JWT::JWA::SigningAlgorithm

Included in:
Ecdsa, Hmac, None, Ps, Rsa, Unsupported
Defined in:
lib/jwt/jwa/signing_algorithm.rb

Overview

Base functionality for signing algorithms

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#algObject (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

#headerObject



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!(message)
  raise(EncodeError.new(message).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!(message)
  raise(DecodeError.new(message).tap { |e| e.set_backtrace(caller(1)) })
end

#signObject



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

Returns:

  • (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

#verifyObject



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