Package openid :: Module association :: Class Association
[frames] | no frames]

Class Association

source code

object --+
         |
        Association

This class represents an association between a server and a consumer. In general, users of this library will never see instances of this object. The only exception is if you implement a custom OpenIDStore.

If you do implement such a store, it will need to store the values of the handle, secret, issued, lifetime, and assoc_type instance variables.

Instance Methods [hide private]
  __init__(self, handle, secret, issued, lifetime, assoc_type)
This is the standard constructor for creating an association.
int getExpiresIn(self, now=None)
This returns the number of seconds this association is still valid for, or 0 if the association is no longer valid.
bool __eq__(self, other)
This checks to see if two Association instances represent the same association.
bool __ne__(self, other)
This checks to see if two Association instances represent different associations.
str serialize(self)
Convert an association to KV form.
str sign(self, pairs)
Generate a signature for a sequence of (key, value) pairs
str signDict(self, fields, data, prefix='openid.')
Generate a signature for some fields in a dictionary
  addSignature(self, fields, data, prefix='openid.')
  checkSignature(self, data, prefix='openid.')

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Class Methods [hide private]
  fromExpiresIn(cls, expires_in, handle, secret, assoc_type)
This is an alternate constructor used by the OpenID consumer library to create associations.
  deserialize(cls, assoc_s)
Parse an association as stored by serialize().

Class Variables [hide private]
  SIG_LENGTH = 20
  assoc_keys = ['version', 'handle', 'secret', 'issued', 'lifetime'...

Instance Variables [hide private]
str handle
This is the handle the server gave this association.
str secret
This is the shared secret the server generated for this association.
int issued
This is the time this association was issued, in seconds since 00:00 GMT, January 1, 1970.
int lifetime
This is the amount of time this association is good for, measured in seconds since the association was issued.
str assoc_type
This is the type of association this instance represents.

Properties [hide private]
  expiresIn

Inherited from object: __class__


Method Details [hide private]

__init__(self, handle, secret, issued, lifetime, assoc_type)
(Constructor)

source code 

This is the standard constructor for creating an association.
Parameters:
  • handle (str) - This is the handle the server gave this association.
  • secret (str) - This is the shared secret the server generated for this association.
  • issued (int) - This is the time this association was issued, in seconds since 00:00 GMT, January 1, 1970. (ie, a unix timestamp)
  • lifetime (int) - This is the amount of time this association is good for, measured in seconds since the association was issued.
  • assoc_type (str) - This is the type of association this instance represents. The only valid value of this field at this time is 'HMAC-SHA1', but new types may be defined in the future.
Overrides: object.__init__

fromExpiresIn(cls, expires_in, handle, secret, assoc_type)
Class Method

source code 

This is an alternate constructor used by the OpenID consumer library to create associations. OpenIDStore implementations shouldn't use this constructor.
Parameters:
  • expires_in (int) - This is the amount of time this association is good for, measured in seconds since the association was issued.
  • handle (str) - This is the handle the server gave this association.
  • secret (str) - This is the shared secret the server generated for this association.
  • assoc_type (str) - This is the type of association this instance represents. The only valid value of this field at this time is 'HMAC-SHA1', but new types may be defined in the future.

getExpiresIn(self, now=None)

source code 

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

__eq__(self, other)
(Equality operator)

source code 

This checks to see if two Association instances represent the same association.
Returns: bool
True if the two instances represent the same association, False otherwise.

__ne__(self, other)

source code 

This checks to see if two Association instances represent different associations.
Returns: bool
True if the two instances represent different associations, False otherwise.

serialize(self)

source code 

Convert an association to KV form.
Returns: str
String in KV form suitable for deserialization by deserialize.

deserialize(cls, assoc_s)
Class Method

source code 

Parse an association as stored by serialize().

inverse of serialize
Parameters:
  • assoc_s (str) - Association as serialized by serialize()
Returns:
instance of this class

sign(self, pairs)

source code 

Generate a signature for a sequence of (key, value) pairs
Parameters:
  • pairs (sequence of (str, str)) - The pairs to sign, in order
Returns: str
The binary signature of this sequence of pairs

signDict(self, fields, data, prefix='openid.')

source code 

Generate a signature for some fields in a dictionary
Parameters:
  • fields (sequence of str) - The fields to sign, in order
  • data ({str:str}) - Dictionary of values to sign
Returns: str
the signature, base64 encoded

addSignature(self, fields, data, prefix='openid.')

source code 

checkSignature(self, data, prefix='openid.')

source code 

Class Variable Details [hide private]

SIG_LENGTH

Value:
20                                                                    
      

assoc_keys

Value:
['version', 'handle', 'secret', 'issued', 'lifetime', 'assoc_type']    
      

Instance Variable Details [hide private]

handle


This is the handle the server gave this association.
Type:
str

secret


This is the shared secret the server generated for this association.
Type:
str

issued


This is the time this association was issued, in seconds since 00:00 GMT, January 1, 1970. (ie, a unix timestamp)
Type:
int

lifetime


This is the amount of time this association is good for, measured in seconds since the association was issued.
Type:
int

assoc_type


This is the type of association this instance represents. The only valid value of this field at this time is 'HMAC-SHA1', but new types may be defined in the future.
Type:
str

Property Details [hide private]

expiresIn

Get Method:
openid.association.Association.getExpiresIn(self, now=None) - This returns the number of seconds this association is still valid for, or 0 if the association is no longer valid.