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
 
__init__(self, handle, secret, issued, lifetime, assoc_type)
This is the standard constructor for creating an association.
source code
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.
source code
bool
__eq__(self, other)
This checks to see if two Association instances represent the same association.
source code
bool
__ne__(self, other)
This checks to see if two Association instances represent different associations.
source code
str
serialize(self)
Convert an association to KV form.
source code
str
sign(self, pairs)
Generate a signature for a sequence of (key, value) pairs
source code
str
getMessageSignature(self, message)
Return the signature of a message.
source code
openid.message.Message
signMessage(self, message)
Add a signature (and a signed list) to a message.
source code
 
checkMessageSignature(self, message)
Given a message with a signature, calculate a new signature and return whether it matches the signature in the message.
source code
 
__repr__(self)
repr(x)
source code

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

Class Methods
 
fromExpiresIn(cls, expires_in, handle, secret, assoc_type)
This is an alternate constructor used by the OpenID consumer library to create associations.
source code
 
deserialize(cls, assoc_s)
Parse an association as stored by serialize().
source code
Class Variables
  assoc_keys = ['version', 'handle', 'secret', 'issued', 'lifeti...
Instance Variables
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
int expiresIn
This returns the number of seconds this association is still valid for, or 0 if the association is no longer valid.

Inherited from object: __class__

Method Details

__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

getMessageSignature(self, message)

source code 

Return the signature of a message.

If I am not a sign-all association, the message must have a signed list.

Returns: str
the signature, base64 encoded
Raises:
  • ValueError - If there is no signed list and I am not a sign-all type of association.

signMessage(self, message)

source code 

Add a signature (and a signed list) to a message.

Returns: openid.message.Message
a new Message object with a signature

checkMessageSignature(self, message)

source code 

Given a message with a signature, calculate a new signature and return whether it matches the signature in the message.

Raises:
  • ValueError - if the message has no signature or no signature can be calculated for it.

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

Class Variable Details

assoc_keys

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

Instance Variable Details

issued

This is the time this association was issued, in seconds since 00:00 GMT, January 1, 1970. (ie, a unix timestamp)
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

expiresIn

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

Get Method:
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.
Type:
int