diff options
-rw-r--r-- | Auth/OpenID/Association.php | 12 | ||||
-rw-r--r-- | Auth/OpenID/Consumer.php | 31 | ||||
-rw-r--r-- | Tests/Auth/OpenID/Consumer.php | 5 |
3 files changed, 29 insertions, 19 deletions
diff --git a/Auth/OpenID/Association.php b/Auth/OpenID/Association.php index 9e7ac14..241d590 100644 --- a/Auth/OpenID/Association.php +++ b/Auth/OpenID/Association.php @@ -370,9 +370,15 @@ function Auth_OpenID_checkSessionType($assoc_type, $session_type) function Auth_OpenID_getDefaultAssociationOrder() { - return array( - array('HMAC-SHA1', 'DH-SHA1'), - array('HMAC-SHA1', 'no-encryption')); + $order = array(); + + if (!defined('Auth_OpenID_NO_MATH_SUPPORT')) { + $order[] = array('HMAC-SHA1', 'DH-SHA1'); + } + + $order[] = array('HMAC-SHA1', 'no-encryption'); + + return $order; } function Auth_OpenID_getOnlyEncryptedOrder() diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php index 3c8ccb6..d7c860e 100644 --- a/Auth/OpenID/Consumer.php +++ b/Auth/OpenID/Consumer.php @@ -479,6 +479,15 @@ class Auth_OpenID_PlainTextConsumerSession { } } +function Auth_OpenID_getAvailableSessionTypes() +{ + $types = array( + 'no-encryption' => 'Auth_OpenID_PlainTextConsumerSession', + 'DH-SHA1' => 'Auth_OpenID_DiffieHellmanSHA1ConsumerSession'); + + return $types; +} + /** * This class is the interface to the OpenID consumer logic. * Instances of it maintain no per-request state, so they can be @@ -524,11 +533,7 @@ class Auth_OpenID_GenericConsumer { $this->fetcher = Services_Yadis_Yadis::getHTTPFetcher(); - $this->session_types = array( - 'DH-SHA1' => 'Auth_OpenID_DiffieHellmanSHA1ConsumerSession', - // 'DH-SHA256' => 'Auth_OpenID_DiffieHellmanSHA256ConsumerSession', - 'no-encryption' => 'Auth_OpenID_PlainTextConsumerSession' - ); + $this->session_types = Auth_OpenID_getAvailableSessionTypes(); } function begin($service_endpoint) @@ -804,14 +809,6 @@ class Auth_OpenID_GenericConsumer { } /** - * @access protected - */ - function _createDiffieHellman() - { - return new Auth_OpenID_DiffieHellman(); - } - - /** * @access private */ function _getAssociation($endpoint) @@ -1000,8 +997,12 @@ class Auth_OpenID_GenericConsumer { function _createAssociateRequest($endpoint, $assoc_type, $session_type) { - $session_type_class = $this->session_types[$session_type]; - $assoc_session = new $session_type_class(); + if (array_key_exists($session_type, $this->session_types)) { + $session_type_class = $this->session_types[$session_type]; + $assoc_session = new $session_type_class(); + } else { + return null; + } $args = array( 'mode' => 'associate', diff --git a/Tests/Auth/OpenID/Consumer.php b/Tests/Auth/OpenID/Consumer.php index e6918b1..15a3537 100644 --- a/Tests/Auth/OpenID/Consumer.php +++ b/Tests/Auth/OpenID/Consumer.php @@ -30,10 +30,12 @@ class Auth_OpenID_TestConsumer extends Auth_OpenID_GenericConsumer { /** * Use a small (insecure) modulus for this test so that it runs quickly */ + /* function _createDiffieHellman() { return new Auth_OpenID_DiffieHellman('1235514290909'); } + */ } $_Auth_OpenID_assocs = array( @@ -68,7 +70,8 @@ function Auth_OpenID_associate($qs, $assoc_secret, $assoc_handle) if (defined('Auth_OpenID_NO_MATH_SUPPORT')) { assert(count($query_data) == 2); - $session = Auth_OpenID_PlainTextServerSession::fromQuery($query_data); + $message = Auth_OpenID_Message::fromPostArgs($query_data); + $session = Auth_OpenID_PlainTextServerSession::fromMessage($message); } else { assert((count($query_data) == 6) || (count($query_data) == 4)); assert($query_data['openid.mode'] == 'associate'); |