Class: JWT::Algos::AlgoWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/jwt/algos/algo_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#algObject (readonly)

Returns the value of attribute alg.



6
7
8
# File 'lib/jwt/algos/algo_wrapper.rb', line 6

def alg
  @alg
end

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

Returns:

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