grnq / joid

Java OpenID = JOID OpenID providers and relying parties for OpenID 1.1 and 2.0
Other
4 stars 0 forks source link

NPE in URLEncoder.encode in MessageParser #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
The problem appears to be intermittent but during some requests to the
openid provider during authentication, one (or possibly more) of the map
values that are being encoded is(are) null for either the key or value.  I
have not been able to confirm the exact cause but this is too drastic a
failure in my opinion.

What is the expected output? What do you see instead?

Caused by: java.lang.NullPointerException
    at java.net.URLEncoder.encode(URLEncoder.java:227)
    at org.verisign.joid.MessageParser.toStringDelimitedBy(MessageParser.java:78)
    at org.verisign.joid.MessageParser.toUrlString(MessageParser.java:59)
    at org.verisign.joid.Message.toUrlString(Message.java:93)
    at org.verisign.joid.consumer.Util.send(Util.java:18)
    at org.verisign.joid.consumer.JoidConsumer.authenticate(JoidConsumer.java:260)

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by tod...@us.ibm.com on 29 Mar 2008 at 1:42

GoogleCodeExporter commented 9 years ago
Suggest null checks and possibly log and throw some type of exception instead of
causing an NPE...

if( key!= null && value != null){
    sb.append(URLEncoder.encode(key, "UTF-8")+kvDelim
        +URLEncoder.encode(value, "UTF-8"));
    if (iter.hasNext()) {
      sb.append(lineDelim);
    }
}else{
    //   do some error handling here
}

Original comment by tod...@us.ibm.com on 29 Mar 2008 at 1:44

GoogleCodeExporter commented 9 years ago
In r97, I've added code to throw an OpenIdException if there is a null value.  
A null
key is quite a bit more disastrous, so we'll still get an NPE in that case.

Original comment by barryf...@gmail.com on 20 Aug 2008 at 6:34