Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UrlBasedVerifierProvider does not work with recent version of gson #5

Open
GoogleCodeExporter opened this issue Mar 14, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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(UrlBasedVeri
fierProvider.java:58)
[INFO]  at 
net.oauth.jsontoken.JsonTokenParser.verifyAndDeserialize(JsonTokenParser.java:10
8)


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.

Original issue reported on code.google.com by [email protected] on 22 Aug 2013 at 8:10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant