diff options
author | tailor <cygnus@janrain.com> | 2008-02-04 20:09:01 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2008-02-04 20:09:01 +0000 |
commit | e6c09bdc9e75d74d456cb5deba8134cd7f36bb44 (patch) | |
tree | 0c40d09d4708b5cb66cc2ef0b5fc8c2ff796d9f4 /Auth/OpenID | |
parent | 9d91a5ac05b028897c764f5a87706a6b89a97ede (diff) | |
download | php-openid-e6c09bdc9e75d74d456cb5deba8134cd7f36bb44.zip php-openid-e6c09bdc9e75d74d456cb5deba8134cd7f36bb44.tar.gz php-openid-e6c09bdc9e75d74d456cb5deba8134cd7f36bb44.tar.bz2 |
[project @ Generalize Auth_OpenID_Association::sign()]
Diffstat (limited to 'Auth/OpenID')
-rw-r--r-- | Auth/OpenID/Association.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Auth/OpenID/Association.php b/Auth/OpenID/Association.php index d234294..904655f 100644 --- a/Auth/OpenID/Association.php +++ b/Auth/OpenID/Association.php @@ -64,6 +64,11 @@ class Auth_OpenID_Association { 'assoc_type' ); + var $_macs = array( + 'HMAC-SHA1' => 'Auth_OpenID_HMACSHA1', + 'HMAC-SHA256' => 'Auth_OpenID_HMACSHA256' + ); + /** * This is an alternate constructor (factory method) used by the * OpenID consumer library to create associations. OpenID store @@ -258,11 +263,11 @@ class Auth_OpenID_Association { function sign($pairs) { $kv = Auth_OpenID_KVForm::fromArray($pairs); - if(Auth_OpenID_HMACSHA256_SUPPORTED - && $this->assoc_type == 'HMAC-SHA256') - return Auth_OpenID_HMACSHA256($this->secret, $kv); + /* Invalid association types should be caught at constructor */ - return Auth_OpenID_HMACSHA1($this->secret, $kv); + $callback = $this->_macs[$this->assoc_type]; + + return call_user_func_array($callback, array($this->secret, $kv)); } /** |