Module: JSON::JOSE::ClassMethods

Defined in:
lib/json/jose.rb

Instance Method Summary collapse

Instance Method Details

#decode(input, key_or_secret = nil, algorithms = nil, encryption_methods = nil, allow_blank_payload = false) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/json/jose.rb', line 59

def decode(input, key_or_secret = nil, algorithms = nil, encryption_methods = nil, allow_blank_payload = false)
  if input.is_a? Hash
    decode_json_serialized input, key_or_secret, algorithms, encryption_methods, allow_blank_payload
  else
    decode_compact_serialized input, key_or_secret, algorithms, encryption_methods, allow_blank_payload
  end
rescue JSON::ParserError, ArgumentError
  raise JWT::InvalidFormat.new("Invalid JSON Format")
end

#register_header_keys(*keys) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/json/jose.rb', line 48

def register_header_keys(*keys)
  keys.each do |header_key|
    define_method header_key do
      self.header[header_key]
    end
    define_method "#{header_key}=" do |value|
      self.header[header_key] = value
    end
  end
end