Class: JSON::JWK
- Inherits:
-
ActiveSupport::HashWithIndifferentAccess
- Object
- ActiveSupport::HashWithIndifferentAccess
- JSON::JWK
- Defined in:
- lib/json/jwk.rb
Defined Under Namespace
Classes: Set, UnknownAlgorithm
Class Method Summary collapse
Instance Method Summary collapse
- #content_type ⇒ Object
-
#initialize(public_key, options = {}) ⇒ JWK
constructor
A new instance of JWK.
Constructor Details
#initialize(public_key, options = {}) ⇒ JWK
Returns a new instance of JWK.
5 6 7 |
# File 'lib/json/jwk.rb', line 5 def initialize(public_key, = {}) replace encode(public_key, ) end |
Class Method Details
.decode(jwk) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/json/jwk.rb', line 65 def decode(jwk) jwk = jwk.with_indifferent_access case jwk[:kty].to_s when 'RSA' e = OpenSSL::BN.new UrlSafeBase64.decode64(jwk[:e]), 2 n = OpenSSL::BN.new UrlSafeBase64.decode64(jwk[:n]), 2 key = OpenSSL::PKey::RSA.new key.e = e key.n = n key when 'EC' raise NotImplementedError.new('Not Implemented Yet') else raise UnknownAlgorithm.new('Unknown Algorithm') end end |
Instance Method Details
#content_type ⇒ Object
9 10 11 |
# File 'lib/json/jwk.rb', line 9 def content_type 'application/jwk+json' end |