Skip to content

UrlBasedVerifierProvider appends null at the end of json read from URL #9

@GoogleCodeExporter

Description

@GoogleCodeExporter
In file  net.oauth.jsontoken.discovery.UrlBasedVerifierProvider.java, method 
public List<Verifier> findVerifier(String issuer, String keyId) 

52        do {
53          line = buff.readLine();
54          content.append(line + "\n");
55        } while (line != null);


57        JsonParser parser = new JsonParser();
58        JsonObject jsonObject = 
parser.parse(content.toString()).getAsJsonObject();


When code reads certificates by fetching from URL which expects simple json 
format, for example:
 {"keyid":"x509 certificate in Pem format", "keyid2":"x509 certificate in Pem format"..}, 

code at 52-55 appends null at the end of json. 

When code 57-58 parses that json, it gives following error:

com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) 
to accept malformed JSON at line 2 column 2 path $


Solution:
          Before appending line to content, make a check if(line != null)

        do {
          line = buff.readLine();

          if(line != null)   
             content.append(line + "\n");

        } while (line != null);


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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions