Auth_OpenID_Association Klassenreferenz


Öffentliche Methoden

 fromExpiresIn ($expires_in, $handle, $secret, $assoc_type)
 Auth_OpenID_Association ($handle, $secret, $issued, $lifetime, $assoc_type)
 getExpiresIn ($now=null)
 equal ($other)
 serialize ()
 deserialize ($class_name, $assoc_s)
 sign ($pairs)
 signMessage ($message)
 _makePairs (&$message)
 getMessageSignature (&$message)
 checkMessageSignature (&$message)

Datenfelder

 $SIG_LENGTH = 20
 $assoc_keys
 $_macs

Ausführliche Beschreibung

Definiert in Zeile 44 der Datei Association.php.


Dokumentation der Elementfunktionen

_makePairs ( &$  message  ) 

Given a Auth_OpenID_Message, return the key/value pairs to be signed according to the signed list in the message. If the message lacks a signed list, return null.

private

Definiert in Zeile 330 der Datei Association.php.

00331     {
00332         $signed = $message->getArg(Auth_OpenID_OPENID_NS, 'signed');
00333         if (!$signed || Auth_OpenID::isFailure($signed)) {
00334             // raise ValueError('Message has no signed list: %s' % (message,))
00335             return null;
00336         }
00337 
00338         $signed_list = explode(',', $signed);
00339         $pairs = array();
00340         $data = $message->toPostArgs();
00341         foreach ($signed_list as $field) {
00342             $pairs[] = array($field, Auth_OpenID::arrayGet($data,
00343                                                            'openid.' .
00344                                                            $field, ''));
00345         }
00346         return $pairs;
00347     }

Auth_OpenID_Association ( handle,
secret,
issued,
lifetime,
assoc_type 
)

This is the standard constructor for creating an association. The library should create all of the necessary associations, so this constructor is not part of the external API.

private

Parameter:
string $handle This is the handle the server gave this association.
string $secret This is the shared secret the server generated for this association.
integer $issued This is the time this association was issued, in seconds since 00:00 GMT, January 1, 1970. (ie, a unix timestamp)
integer $lifetime This is the amount of time this association is good for, measured in seconds since the association was issued.
string $assoc_type This is the type of association this instance represents. The only valid values of this field at this time is 'HMAC-SHA1' and 'HMAC-SHA256', but new types may be defined in the future.

Definiert in Zeile 131 der Datei Association.php.

00133     {
00134         if (!in_array($assoc_type,
00135                       Auth_OpenID_getSupportedAssociationTypes())) {
00136             $fmt = 'Unsupported association type (%s)';
00137             trigger_error(sprintf($fmt, $assoc_type), E_USER_ERROR);
00138         }
00139 
00140         $this->handle = $handle;
00141         $this->secret = $secret;
00142         $this->issued = $issued;
00143         $this->lifetime = $lifetime;
00144         $this->assoc_type = $assoc_type;
00145     }

checkMessageSignature ( &$  message  ) 

Confirm that the signature of these fields matches the signature contained in the data.

private

Definiert in Zeile 367 der Datei Association.php.

00368     {
00369         $sig = $message->getArg(Auth_OpenID_OPENID_NS,
00370                                 'sig');
00371 
00372         if (!$sig || Auth_OpenID::isFailure($sig)) {
00373             return false;
00374         }
00375 
00376         $calculated_sig = $this->getMessageSignature($message);
00377         return $calculated_sig == $sig;
00378     }

deserialize ( class_name,
assoc_s 
)

Parse an association as stored by serialize(). This is the inverse of serialize.

Parameter:
string $assoc_s Association as serialized by serialize()
Rückgabe:
Auth_OpenID_Association $result instance of this class

Definiert in Zeile 209 der Datei Association.php.

00210     {
00211         $pairs = Auth_OpenID_KVForm::toArray($assoc_s, $strict = true);
00212         $keys = array();
00213         $values = array();
00214         foreach ($pairs as $key => $value) {
00215             if (is_array($value)) {
00216                 list($key, $value) = $value;
00217             }
00218             $keys[] = $key;
00219             $values[] = $value;
00220         }
00221 
00222         $class_vars = get_class_vars($class_name);
00223         $class_assoc_keys = $class_vars['assoc_keys'];
00224 
00225         sort($keys);
00226         sort($class_assoc_keys);
00227 
00228         if ($keys != $class_assoc_keys) {
00229             trigger_error('Unexpected key values: ' . var_export($keys, true),
00230                           E_USER_WARNING);
00231             return null;
00232         }
00233 
00234         $version = $pairs['version'];
00235         $handle = $pairs['handle'];
00236         $secret = $pairs['secret'];
00237         $issued = $pairs['issued'];
00238         $lifetime = $pairs['lifetime'];
00239         $assoc_type = $pairs['assoc_type'];
00240 
00241         if ($version != '2') {
00242             trigger_error('Unknown version: ' . $version, E_USER_WARNING);
00243             return null;
00244         }
00245 
00246         $issued = intval($issued);
00247         $lifetime = intval($lifetime);
00248         $secret = base64_decode($secret);
00249 
00250         return new $class_name(
00251             $handle, $secret, $issued, $lifetime, $assoc_type);
00252     }

equal ( other  ) 

This checks to see if two Auth_OpenID_Association instances represent the same association.

Rückgabe:
bool $result true if the two instances represent the same association, false otherwise.

Definiert in Zeile 170 der Datei Association.php.

00171     {
00172         return ((gettype($this) == gettype($other))
00173                 && ($this->handle == $other->handle)
00174                 && ($this->secret == $other->secret)
00175                 && ($this->issued == $other->issued)
00176                 && ($this->lifetime == $other->lifetime)
00177                 && ($this->assoc_type == $other->assoc_type));
00178     }

fromExpiresIn ( expires_in,
handle,
secret,
assoc_type 
)

This is an alternate constructor (factory method) used by the OpenID consumer library to create associations. OpenID store implementations shouldn't use this constructor.

private

Parameter:
integer $expires_in This is the amount of time this association is good for, measured in seconds since the association was issued.
string $handle This is the handle the server gave this association.
string secret This is the shared secret the server generated for this association.
assoc_type This is the type of association this instance represents. The only valid values of this field at this time is 'HMAC-SHA1' and 'HMAC-SHA256', but new types may be defined in the future.
Rückgabe:
association An Auth_OpenID_Association instance.

Definiert in Zeile 97 der Datei Association.php.

00098     {
00099         $issued = time();
00100         $lifetime = $expires_in;
00101         return new Auth_OpenID_Association($handle, $secret,
00102                                            $issued, $lifetime, $assoc_type);
00103     }

getExpiresIn ( now = null  ) 

This returns the number of seconds this association is still valid for, or 0 if the association is no longer valid.

Rückgabe:
integer $seconds The number of seconds this association is still valid for, or 0 if the association is no longer valid.

Definiert in Zeile 154 der Datei Association.php.

00155     {
00156         if ($now == null) {
00157             $now = time();
00158         }
00159 
00160         return max(0, $this->issued + $this->lifetime - $now);
00161     }

getMessageSignature ( &$  message  ) 

Given an Auth_OpenID_Message, return the signature for the signed list in the message.

private

Definiert in Zeile 355 der Datei Association.php.

00356     {
00357         $pairs = $this->_makePairs($message);
00358         return base64_encode($this->sign($pairs));
00359     }

serialize (  ) 

Convert an association to KV form.

Rückgabe:
string $result String in KV form suitable for deserialization by deserialize.

Definiert in Zeile 186 der Datei Association.php.

00187     {
00188         $data = array(
00189                      'version' => '2',
00190                      'handle' => $this->handle,
00191                      'secret' => base64_encode($this->secret),
00192                      'issued' => strval(intval($this->issued)),
00193                      'lifetime' => strval(intval($this->lifetime)),
00194                      'assoc_type' => $this->assoc_type
00195                      );
00196 
00197         assert(array_keys($data) == $this->assoc_keys);
00198 
00199         return Auth_OpenID_KVForm::fromArray($data, $strict = true);
00200     }

sign ( pairs  ) 

Generate a signature for a sequence of (key, value) pairs

private

Parameter:
array $pairs The pairs to sign, in order. This is an array of two-tuples.
Rückgabe:
string $signature The binary signature of this sequence of pairs

Definiert in Zeile 263 der Datei Association.php.

00264     {
00265         $kv = Auth_OpenID_KVForm::fromArray($pairs);
00266 
00267         /* Invalid association types should be caught at constructor */
00268         $callback = $this->_macs[$this->assoc_type];
00269 
00270         return call_user_func_array($callback, array($this->secret, $kv));
00271     }

signMessage ( message  ) 

Generate a signature for some fields in a dictionary

private

Parameter:
array $fields The fields to sign, in order; this is an array of strings.
array $data Dictionary of values to sign (an array of string => string pairs).
Rückgabe:
string $signature The signature, base64 encoded

Definiert in Zeile 283 der Datei Association.php.

00284     {
00285         if ($message->hasKey(Auth_OpenID_OPENID_NS, 'sig') ||
00286             $message->hasKey(Auth_OpenID_OPENID_NS, 'signed')) {
00287             // Already has a sig
00288             return null;
00289         }
00290 
00291         $extant_handle = $message->getArg(Auth_OpenID_OPENID_NS,
00292                                           'assoc_handle');
00293 
00294         if ($extant_handle && ($extant_handle != $this->handle)) {
00295             // raise ValueError("Message has a different association handle")
00296             return null;
00297         }
00298 
00299         $signed_message = $message;
00300         $signed_message->setArg(Auth_OpenID_OPENID_NS, 'assoc_handle',
00301                                 $this->handle);
00302 
00303         $message_keys = array_keys($signed_message->toPostArgs());
00304         $signed_list = array();
00305         $signed_prefix = 'openid.';
00306 
00307         foreach ($message_keys as $k) {
00308             if (strpos($k, $signed_prefix) === 0) {
00309                 $signed_list[] = substr($k, strlen($signed_prefix));
00310             }
00311         }
00312 
00313         $signed_list[] = 'signed';
00314         sort($signed_list);
00315 
00316         $signed_message->setArg(Auth_OpenID_OPENID_NS, 'signed',
00317                                 implode(',', $signed_list));
00318         $sig = $this->getMessageSignature($signed_message);
00319         $signed_message->setArg(Auth_OpenID_OPENID_NS, 'sig', $sig);
00320         return $signed_message;
00321     }


Dokumentation der Datenelemente

$_macs

Initialisierung:

 array(
                       'HMAC-SHA1' => 'Auth_OpenID_HMACSHA1',
                       'HMAC-SHA256' => 'Auth_OpenID_HMACSHA256'
                       )

Definiert in Zeile 67 der Datei Association.php.

$assoc_keys

Initialisierung:

 array(
                            'version',
                            'handle',
                            'secret',
                            'issued',
                            'lifetime',
                            'assoc_type'
                            )
The ordering and name of keys as stored by serialize.

private

Definiert in Zeile 58 der Datei Association.php.

$SIG_LENGTH = 20

This is a HMAC-SHA1 specific value.

private

Definiert in Zeile 51 der Datei Association.php.


Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei:
Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved.
MyOOS [Shopsystem] is Free Software released under the GNU/GPL License.

Webmaster: info@r23.de (Impressum)
doxygen