Skip to content

UrlBasedVerifierProvider does not work with recent version of gson #5

@GoogleCodeExporter

Description

@GoogleCodeExporter
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 aurelien...@gmail.com on 22 Aug 2013 at 8:10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions