Back to index

plone3  3.1.7
keymanager.py
Go to the documentation of this file.
00001 from zope.interface import implements
00002 from zope.app.container.sample import SampleContainer
00003 from persistent.mapping import PersistentMapping
00004 from plone.keyring.interfaces import IKeyManager
00005 from plone.keyring.keyring import Keyring
00006 
00007 class KeyManager(SampleContainer):
00008     implements(IKeyManager)
00009 
00010     def __init__(self):
00011         SampleContainer.__init__(self)
00012         self[u"_system"]=Keyring()
00013         self[u"_system"].rotate()
00014 
00015 
00016     def _newContainerData(self):
00017         return PersistentMapping()
00018 
00019 
00020     def clear(self, ring=u"_system"):
00021         if ring is None:
00022             for ring in self.values():
00023                 ring.clear()
00024         else:
00025             self[ring].clear()
00026 
00027 
00028     def rotate(self, ring=u"_system"):
00029         if ring is None:
00030             for ring in self.values():
00031                 ring.rotate()
00032         else:
00033             self[ring].rotate()
00034 
00035 
00036     def secret(self, ring=u"_system"):
00037         return self[ring].current
00038