Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
plone.openid.store.ZopeStore Class Reference
Inheritance diagram for plone.openid.store.ZopeStore:
Inheritance graph
[legend]
Collaboration diagram for plone.openid.store.ZopeStore:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getAssociationKey
def storeAssociation
def getAssociation
def removeAssociation
def useNonce
def cleanupNonces
def cleanupAssociations

Public Attributes

 associations
 handles
 nonces
 noncetimeline
 assoctimeline

Detailed Description

Zope OpenID store.

This class implements an OpenID store which uses the ZODB.

Definition at line 9 of file store.py.


Constructor & Destructor Documentation

Definition at line 14 of file store.py.

00014 
00015     def __init__(self):
00016         self.associations=OOBTree()
00017         self.handles=OOBTree()
00018         self.nonces=OITreeSet()
00019 
00020         self.noncetimeline=PersistentList()
00021         self.assoctimeline=PersistentList()
00022 

Here is the caller graph for this function:


Member Function Documentation

Definition at line 112 of file store.py.

00112 
00113     def cleanupAssociations(self):
00114         if not hasattr(self, "assoctimeline"):
00115             return 0
00116 
00117         now=time.time()
00118         count=0
00119 
00120         expired=(key for (timestamp,key) in self.assoctimeline
00121                 if timestamp<=now)
00122         for key in expired:
00123             self.removeAssociation(*key)
00124             count+=1
00125 
00126         return count
00127 

Here is the call graph for this function:

Definition at line 97 of file store.py.

00097 
00098     def cleanupNonces(self):
00099         if not hasattr(self, "noncetimeline"):
00100             return 0
00101 
00102         cutoff=time.time()+SKEW
00103         count=0
00104         for (timestamp,nonce) in self.noncetimeline:
00105             if timestamp<cutoff:
00106                 self.noncetimeline.remove((timestamp,nonce))
00107                 self.nonces.remove(nonce)
00108                 count+=1
00109 
00110         return count
00111 

def plone.openid.store.ZopeStore.getAssociation (   self,
  server_url,
  handle = None,
  remove = True 
)

Definition at line 52 of file store.py.

00052 
00053     def getAssociation(self, server_url, handle=None, remove=True):
00054         try:
00055             key=self.getAssociationKey(server_url, handle)
00056             assoc=Association.deserialize(self.associations[key])
00057         except KeyError:
00058             return None
00059 
00060         if remove and assoc.getExpiresIn()==0:
00061             self.removeAssociation(server_url, handle)
00062             return None
00063 
00064         return assoc
00065 

Here is the call graph for this function:

Here is the caller graph for this function:

def plone.openid.store.ZopeStore.getAssociationKey (   self,
  server_url,
  handle 
)
Generate a key used to identify an association in our storage.

Definition at line 23 of file store.py.

00023 
00024     def getAssociationKey(self, server_url, handle):
00025         """Generate a key used to identify an association in our storage.
00026         """
00027         if handle is None:
00028             return self.handles[server_url][0]
00029 
00030         return (server_url, handle)
00031 

Here is the caller graph for this function:

def plone.openid.store.ZopeStore.removeAssociation (   self,
  server_url,
  handle 
)

Definition at line 66 of file store.py.

00066 
00067     def removeAssociation(self, server_url, handle):
00068         key=self.getAssociationKey(server_url, handle)
00069         try:
00070             assoc=Association.deserialize(self.associations[key])
00071             del self.associations[key]
00072 
00073             lst=self.handles[server_url]
00074             lst.remove(key)
00075             self.handles[server_url]=lst
00076 
00077             self.assoctimeline.remove((assoc.issued+assoc.lifetime, key))
00078             return True
00079         except KeyError:
00080             return False
00081 

Here is the call graph for this function:

Here is the caller graph for this function:

def plone.openid.store.ZopeStore.storeAssociation (   self,
  server_url,
  association 
)

Definition at line 32 of file store.py.

00032 
00033     def storeAssociation(self, server_url, association):
00034         key=self.getAssociationKey(server_url, association.handle)
00035         self.associations[key]=association.serialize()
00036 
00037         now=time.time()
00038         def getKey(item):
00039             return self.getAssociation(item[0], item[1], remove=False).getExpiresIn(now)
00040 
00041         lst=self.handles.get(server_url, [])
00042         lst.append(key)
00043         lst.sort(key=getKey)
00044         self.handles[server_url]=lst
00045 
00046         if not hasattr(self, "assoctimeline"):
00047             # BBB for versions < 1.0b2
00048             self.assoctimeline=PersistentList()
00049 
00050         self.assoctimeline.append((association.issued+association.lifetime, key))
00051 

Here is the call graph for this function:

def plone.openid.store.ZopeStore.useNonce (   self,
  server_url,
  timestamp,
  salt 
)

Definition at line 82 of file store.py.

00082 
00083     def useNonce(self, server_url, timestamp, salt):
00084         nonce = (salt, server_url)
00085         if nonce in self.nonces:
00086             return False
00087 
00088         self.nonces.insert(nonce)
00089 
00090         if not hasattr(self, "noncetimeline"):
00091             # BBB for store instances from before 1.0b2
00092             self.noncetimeline=PersistentList()
00093         self.noncetimeline.append((timestamp, nonce))
00094 
00095         return True
00096 


Member Data Documentation

Definition at line 15 of file store.py.

Definition at line 20 of file store.py.

Definition at line 16 of file store.py.

Definition at line 17 of file store.py.

Definition at line 19 of file store.py.


The documentation for this class was generated from the following file: