summaryrefslogtreecommitdiffstats
path: root/Auth
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2007-03-07 17:30:06 +0000
committertailor <cygnus@janrain.com>2007-03-07 17:30:06 +0000
commit8e421ce7d9051927fa29b040a23528659833bbe0 (patch)
tree792ac03b82d0d805f4c8e447a7236645e6bf2df1 /Auth
parent9807f88ec4e58e4fa6a34614f50a3b4b6f554b55 (diff)
downloadphp-openid-8e421ce7d9051927fa29b040a23528659833bbe0.zip
php-openid-8e421ce7d9051927fa29b040a23528659833bbe0.tar.gz
php-openid-8e421ce7d9051927fa29b040a23528659833bbe0.tar.bz2
[project @ Add association response tests]
Diffstat (limited to 'Auth')
-rw-r--r--Auth/OpenID.php14
-rw-r--r--Auth/OpenID/Consumer.php22
2 files changed, 35 insertions, 1 deletions
diff --git a/Auth/OpenID.php b/Auth/OpenID.php
index d5870d3..5a3aa96 100644
--- a/Auth/OpenID.php
+++ b/Auth/OpenID.php
@@ -444,6 +444,20 @@ class Auth_OpenID {
return $url;
}
+
+ /**
+ * Replacement (wrapper) for PHP's intval() because it's broken.
+ */
+ function intval($value)
+ {
+ $re = "/^\\d+$/";
+
+ if (!preg_match($re, $value)) {
+ return false;
+ }
+
+ return intval($value);
+ }
}
?> \ No newline at end of file
diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php
index 014f6d5..1859f5c 100644
--- a/Auth/OpenID/Consumer.php
+++ b/Auth/OpenID/Consumer.php
@@ -1343,10 +1343,20 @@ class Auth_OpenID_GenericConsumer {
Auth_OpenID_OPENID_NS, 'assoc_type',
Auth_OpenID_NO_DEFAULT);
+ if ($assoc_type === null) {
+ return new Auth_OpenID_FailureResponse(null,
+ 'assoc_type missing from association response');
+ }
+
$assoc_handle = $assoc_response->getArg(
Auth_OpenID_OPENID_NS, 'assoc_handle',
Auth_OpenID_NO_DEFAULT);
+ if ($assoc_handle === null) {
+ return new Auth_OpenID_FailureResponse(null,
+ 'assoc_handle missing from association response');
+ }
+
// expires_in is a base-10 string. The Python parsing will
// accept literals that have whitespace around them and will
// accept negative values. Neither of these are really in-spec,
@@ -1355,7 +1365,12 @@ class Auth_OpenID_GenericConsumer {
Auth_OpenID_OPENID_NS, 'expires_in',
Auth_OpenID_NO_DEFAULT);
- $expires_in = intval($expires_in_str);
+ if ($expires_in_str === null) {
+ return new Auth_OpenID_FailureResponse(null,
+ 'expires_in missing from association response');
+ }
+
+ $expires_in = Auth_OpenID::intval($expires_in_str);
if ($expires_in === false) {
return null;
}
@@ -1367,6 +1382,11 @@ class Auth_OpenID_GenericConsumer {
$session_type = $assoc_response->getArg(
Auth_OpenID_OPENID2_NS, 'session_type',
Auth_OpenID_NO_DEFAULT);
+
+ if ($session_type === null) {
+ return new Auth_OpenID_FailureResponse(null,
+ 'session_type missing from association response');
+ }
}
// Session type mismatch