Module: JWT::JWA

Defined in:
lib/jwt/jwa.rb,
lib/jwt/jwa/ps.rb,
lib/jwt/jwa/rsa.rb,
lib/jwt/jwa/hmac.rb,
lib/jwt/jwa/none.rb,
lib/jwt/jwa/ecdsa.rb,
lib/jwt/jwa/eddsa.rb,
lib/jwt/jwa/wrapper.rb,
lib/jwt/jwa/hmac_rbnacl.rb,
lib/jwt/jwa/unsupported.rb,
lib/jwt/jwa/hmac_rbnacl_fixed.rb,
lib/jwt/jwa/signing_algorithm.rb

Defined Under Namespace

Modules: SigningAlgorithm, Unsupported Classes: Ecdsa, Eddsa, Hmac, HmacRbNaCl, HmacRbNaClFixed, None, Ps, Rsa, Wrapper

Class Method Summary collapse

Class Method Details

.find(algo) ⇒ Object



48
49
50
# File 'lib/jwt/jwa/signing_algorithm.rb', line 48

def find(algo)
  algorithms.fetch(algo.to_s.downcase, Unsupported)
end

.register_algorithm(algo) ⇒ Object



44
45
46
# File 'lib/jwt/jwa/signing_algorithm.rb', line 44

def register_algorithm(algo)
  algorithms[algo.alg.to_s.downcase] = algo
end

.resolve(algorithm) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/jwt/jwa.rb', line 33

def resolve(algorithm)
  return find(algorithm) if algorithm.is_a?(String) || algorithm.is_a?(Symbol)

  unless algorithm.is_a?(SigningAlgorithm)
    Deprecations.warning('Custom algorithms are required to include JWT::JWA::SigningAlgorithm')
    return Wrapper.new(algorithm)
  end

  algorithm
end