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
-
#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
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/json/jwk.rb', line 61 def decode(jwk) 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 |