149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# File 'lib/json/jws.rb', line 149
def decode_compact_serialized(input, public_key_or_secret)
unless input.count('.') + 1 == NUM_OF_SEGMENTS
raise InvalidFormat.new("Invalid JWS Format. JWS should include #{NUM_OF_SEGMENTS} segments.")
end
, claims, signature = input.split('.', JWS::NUM_OF_SEGMENTS).collect do |segment|
UrlSafeBase64.decode64 segment.to_s
end
, claims = [, claims].collect do |json|
MultiJson.load(json).with_indifferent_access
end
jws = new claims
jws. =
jws.signature = signature
jws.signature_base_string = input.split('.')[0, JWS::NUM_OF_SEGMENTS - 1].join('.')
jws.verify! public_key_or_secret unless public_key_or_secret == :skip_verification
jws
end
|