bnitay / openid4java

Automatically exported from code.google.com/p/openid4java
Apache License 2.0
0 stars 0 forks source link

NumberFormatException on PAPE max_auth_age #190

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
A malformed PAPE request that sends max_auth_age as a non-integer causes 
PapeRequest.getMaxAuthAge() to throw a NumberFormatException , which is not 
declared in the method signature or mentioned in the javadoc.

Should either handle the error internally or make it obvious to API users about 
this behavior.  

Here is how I handle it:

Index: src/org/openid4java/message/pape/PapeRequest.java
===================================================================
--- src/org/openid4java/message/pape/PapeRequest.java   (revision 733)
+++ src/org/openid4java/message/pape/PapeRequest.java   (working copy)
@@ -160,9 +160,13 @@
     {
         String maxAuthAge = getParameterValue("max_auth_age");

-        if (maxAuthAge != null)
-            return Integer.parseInt(maxAuthAge);
-        else
+        if (maxAuthAge != null) {
+            try {
+                return Integer.parseInt(maxAuthAge);
+            } catch (NumberFormatException e) {
+                return -1;
+            }
+        } else
             return -1;
     }

Original issue reported on code.google.com by j...@slushpupie.com on 8 Feb 2013 at 6:11