Class: LightJWT::JWK::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/light_jwt/jwk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key_data) ⇒ Key

Returns a new instance of Key.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/light_jwt/jwk.rb', line 30

def initialize(key_data)
  @key_data = key_data
  @kty = key_data['kty']
  @use = key_data['use']
  @alg = key_data['alg']
  @kid = key_data['kid']
  @n = key_data['n']
  @e = key_data['e']
  @x = key_data['x']
  @y = key_data['y']
  @crv = key_data['crv']

  validate_key
end

Instance Attribute Details

#algObject (readonly)

Returns the value of attribute alg.



28
29
30
# File 'lib/light_jwt/jwk.rb', line 28

def alg
  @alg
end

#crvObject (readonly)

Returns the value of attribute crv.



28
29
30
# File 'lib/light_jwt/jwk.rb', line 28

def crv
  @crv
end

#eObject (readonly)

Returns the value of attribute e.



28
29
30
# File 'lib/light_jwt/jwk.rb', line 28

def e
  @e
end

#key_dataObject (readonly)

Returns the value of attribute key_data.



28
29
30
# File 'lib/light_jwt/jwk.rb', line 28

def key_data
  @key_data
end

#kidObject (readonly)

Returns the value of attribute kid.



28
29
30
# File 'lib/light_jwt/jwk.rb', line 28

def kid
  @kid
end

#ktyObject (readonly)

Returns the value of attribute kty.



28
29
30
# File 'lib/light_jwt/jwk.rb', line 28

def kty
  @kty
end

#nObject (readonly)

Returns the value of attribute n.



28
29
30
# File 'lib/light_jwt/jwk.rb', line 28

def n
  @n
end

#useObject (readonly)

Returns the value of attribute use.



28
29
30
# File 'lib/light_jwt/jwk.rb', line 28

def use
  @use
end

#xObject (readonly)

Returns the value of attribute x.



28
29
30
# File 'lib/light_jwt/jwk.rb', line 28

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



28
29
30
# File 'lib/light_jwt/jwk.rb', line 28

def y
  @y
end

Instance Method Details

#public_keyObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/light_jwt/jwk.rb', line 45

def public_key
  case kty
  when 'RSA'
    build_rsa_public_key
  when 'EC'
    build_ec_public_key
  else
    raise ArgumentError, "Unsupported key type: #{kty}"
  end
end