summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2008-02-07 21:19:08 +0000
committertailor <cygnus@janrain.com>2008-02-07 21:19:08 +0000
commit1af2d62be0011b1a5de659de280b811bfbcf0ff7 (patch)
tree9cab4f40856c55642e9b2eb352f1037662bdaf70
parente6c09bdc9e75d74d456cb5deba8134cd7f36bb44 (diff)
downloadphp-openid-1af2d62be0011b1a5de659de280b811bfbcf0ff7.zip
php-openid-1af2d62be0011b1a5de659de280b811bfbcf0ff7.tar.gz
php-openid-1af2d62be0011b1a5de659de280b811bfbcf0ff7.tar.bz2
[project @ Add HMAC-SHA256 to plaintext consumer session assoc types]
-rw-r--r--Auth/OpenID/Consumer.php2
-rw-r--r--Tests/Auth/OpenID/Consumer.php37
2 files changed, 38 insertions, 1 deletions
diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php
index 7c1e6d5..d5fd53f 100644
--- a/Auth/OpenID/Consumer.php
+++ b/Auth/OpenID/Consumer.php
@@ -518,7 +518,7 @@ class Auth_OpenID_DiffieHellmanSHA256ConsumerSession extends
*/
class Auth_OpenID_PlainTextConsumerSession {
var $session_type = 'no-encryption';
- var $allowed_assoc_types = array('HMAC-SHA1');
+ var $allowed_assoc_types = array('HMAC-SHA1', 'HMAC-SHA256');
function getRequest()
{
diff --git a/Tests/Auth/OpenID/Consumer.php b/Tests/Auth/OpenID/Consumer.php
index eb516a7..afa47df 100644
--- a/Tests/Auth/OpenID/Consumer.php
+++ b/Tests/Auth/OpenID/Consumer.php
@@ -2218,6 +2218,43 @@ class TestCreateAssociationRequest extends PHPUnit_TestCase {
$args->toPostArgs());
}
+ function test_noEncryptionSendsTypeHMACSHA256()
+ {
+ $session_type = 'no-encryption';
+ $this->assoc_type = 'HMAC-SHA256';
+
+ list($session, $args) = $this->consumer->_createAssociateRequest(
+ $this->endpoint, $this->assoc_type, $session_type);
+
+ $this->assertTrue(is_a($session, 'Auth_OpenID_PlainTextConsumerSession'));
+
+ $expected = Auth_OpenID_Message::fromOpenIDArgs(
+ array('ns' => Auth_OpenID_OPENID2_NS,
+ 'session_type'=>$session_type,
+ 'mode'=>'associate',
+ 'assoc_type'=>$this->assoc_type));
+
+ $this->assertEquals($expected->toPostArgs(),
+ $args->toPostArgs());
+
+ $response = Auth_OpenID_Message::fromOpenIDArgs(
+ array('ns' => Auth_OpenID_OPENID2_NS,
+ 'session_type'=>$session_type,
+ 'assoc_type'=>$this->assoc_type,
+ 'expires_in' => '10000000000',
+ 'mac_key' => 'ZM9v',
+ 'assoc_handle' => 'turnme'
+ )
+ );
+
+ $assoc = $this->consumer->_extractAssociation($response, $session);
+
+ $this->assertTrue($assoc !== null);
+ $this->assertTrue(is_a($assoc, 'Auth_OpenID_Association'));
+ $this->assertTrue($assoc->assoc_type = $this->assoc_type);
+ $this->assertTrue($assoc->session_type = $session_type);
+ }
+
function test_noEncryptionCompatibility()
{
$this->endpoint->use_compatibility = true;