Class: Auth0RS256JWTVerifier::JWK

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

Defined Under Namespace

Classes: JWKMember, X5C

Constant Summary collapse

ParseError =
Class.new(RuntimeError)
Kty =
Class.new(RequiredStringJWKMember)
Use =
Class.new(OptionalStringJWKMember)
Alg =
Class.new(OptionalStringJWKMember)
N =
Class.new(OptionalStringJWKMember)
E =
Class.new(OptionalStringJWKMember)
Kid =
Class.new(OptionalStringJWKMember)
X5T =
Class.new(OptionalStringJWKMember)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ JWK

Returns a new instance of JWK.

Raises:



128
129
130
131
132
133
134
# File 'lib/auth0_rs256_jwt_verifier/jwk.rb', line 128

def initialize(hash)
  raise ParseError unless hash.is_a?(Hash)
  %i(Alg Kty Use X5C N E Kid X5T).each do |field_name|
    field = self.class.const_get(field_name).new(hash[String(field_name).downcase])
    instance_variable_set("@#{String(field_name).downcase}", field)
  end
end

Instance Attribute Details

#algObject (readonly)

Returns the value of attribute alg.



136
137
138
# File 'lib/auth0_rs256_jwt_verifier/jwk.rb', line 136

def alg
  @alg
end

#eObject (readonly)

Returns the value of attribute e.



136
137
138
# File 'lib/auth0_rs256_jwt_verifier/jwk.rb', line 136

def e
  @e
end

#kidObject (readonly)

Returns the value of attribute kid.



136
137
138
# File 'lib/auth0_rs256_jwt_verifier/jwk.rb', line 136

def kid
  @kid
end

#ktyObject (readonly)

Returns the value of attribute kty.



136
137
138
# File 'lib/auth0_rs256_jwt_verifier/jwk.rb', line 136

def kty
  @kty
end

#nObject (readonly)

Returns the value of attribute n.



136
137
138
# File 'lib/auth0_rs256_jwt_verifier/jwk.rb', line 136

def n
  @n
end

#useObject (readonly)

Returns the value of attribute use.



136
137
138
# File 'lib/auth0_rs256_jwt_verifier/jwk.rb', line 136

def use
  @use
end

#x5cObject (readonly)

Returns the value of attribute x5c.



136
137
138
# File 'lib/auth0_rs256_jwt_verifier/jwk.rb', line 136

def x5c
  @x5c
end

#x5tObject (readonly)

Returns the value of attribute x5t.



136
137
138
# File 'lib/auth0_rs256_jwt_verifier/jwk.rb', line 136

def x5t
  @x5t
end

Instance Method Details

#inspectObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/auth0_rs256_jwt_verifier/jwk.rb', line 6

def inspect
  "JWK(\n"                    \
  "\talg: #{@alg},\n"         \
  "\tkty: #{@kty},\n"         \
  "\tuse: #{@use},\n"         \
  "\tx5c: #{@x5c.inspect.split("\n").map { |l| "\t#{l}" }.join("\n")},\n" \
  "\tn: #{@n},\n"             \
  "\te: #{@e},\n"             \
  "\tkid: #{@kid},\n"         \
  "\tx5t: #{@x5t}\n"          \
  ")"
end