Module: SyrupPay::JweSupportAlgorithm

Included in:
JweSerializer
Defined in:
lib/jose/jwe/jwe.rb

Constant Summary collapse

ALG =
[:A128KW, :A256KW]
ENC =
[:'A128CBC-HS256']

Instance Method Summary collapse

Instance Method Details

#alg?(alg) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/jose/jwe/jwe.rb', line 11

def alg?(alg)
  ALG.include? alg
end

#enc?(enc) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/jose/jwe/jwe.rb', line 15

def enc?(enc)
  ENC.include? enc
end

#encryption_algorithm?(enc) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
# File 'lib/jose/jwe/jwe.rb', line 27

def encryption_algorithm?(enc)
  case enc
    when :'A128CBC-HS256' then SyrupPay::Jwa::A128CbcHmac256Encryption.new
    else nil
  end
end

#json_to_hash(json) ⇒ Object



34
35
36
# File 'lib/jose/jwe/jwe.rb', line 34

def json_to_hash(json)
  ActiveSupport::JSON.decode(json).with_indifferent_access
end

#keywrap_algorithm?(alg) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
# File 'lib/jose/jwe/jwe.rb', line 19

def keywrap_algorithm?(alg)
  case alg
    when :A128KW then SyrupPay::Jwa::A128Kw.new
    when :A256KW then SyrupPay::Jwa::A256Kw.new
    else nil
    end
end