Export to GitHub

jsontoken - issue #5

UrlBasedVerifierProvider does not work with recent version of gson


Posted on Aug 22, 2013 by Swift Bear

What steps will reproduce the problem? 1. In pom.xml switch to a recent version of gson, 2.2.4 for example 2. Use UrlBasedVerifierProvider to fetch a certicate from an url. 3.

What is the expected output? What do you see instead? I should get a List<Verifier>

I get an exception [INFO] com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2 [INFO] at com.google.gson.JsonParser.parse(JsonParser.java:65) [INFO] at com.google.gson.JsonParser.parse(JsonParser.java:45) [INFO] at net.oauth.jsontoken.discovery.UrlBasedVerifierProvider.findVerifier(UrlBasedVerifierProvider.java:58) [INFO] at net.oauth.jsontoken.JsonTokenParser.verifyAndDeserialize(JsonTokenParser.java:108)

How to Fix it @ https://code.google.com/p/jsontoken/source/browse/trunk/src/main/java/net/oauth/jsontoken/discovery/UrlBasedVerifierProvider.java#51

replace String line = ""; do { line = buff.readLine(); content.append(line + "\n"); } while (line != null);

with String line = buff.readLine(); while (line != null) { content.append(line + "\n"); line = buff.readLine(); } ;

The later won't add an unwanted "null" string at the end of the json string.

Comment #1

Posted on Mar 24, 2015 by Swift Panda

I am encountering this issue as well

Status: New

Labels:
Type-Defect Priority-Medium