Package flumotion :: Package component :: Package bouncers :: Module component
[hide private]

Source Code for Module flumotion.component.bouncers.component

  1  # -*- Mode: Python -*- 
  2  # vi:si:et:sw=4:sts=4:ts=4 
  3  # 
  4  # Flumotion - a streaming media server 
  5  # Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com). 
  6  # All rights reserved. 
  7   
  8  # This file may be distributed and/or modified under the terms of 
  9  # the GNU General Public License version 2 as published by 
 10  # the Free Software Foundation. 
 11  # This file is distributed without any warranty; without even the implied 
 12  # warranty of merchantability or fitness for a particular purpose. 
 13  # See "LICENSE.GPL" in the source distribution for more information. 
 14   
 15  # Licensees having purchased or holding a valid Flumotion Advanced 
 16  # Streaming Server license may use this file in accordance with the 
 17  # Flumotion Advanced Streaming Server Commercial License Agreement. 
 18  # See "LICENSE.Flumotion" in the source distribution for more information. 
 19   
 20  # Headers in this file shall remain intact. 
 21   
 22  from flumotion.component import component 
 23   
 24  __all__ = ['Bouncer'] 
 25  __version__ = "$Rev: 6125 $" 
 26   
 27   
28 -class BouncerMedium(component.BaseComponentMedium):
29 30 logCategory = 'bouncermedium'
31 - def remote_authenticate(self, keycard):
32 """ 33 Authenticates the given keycard. 34 35 @type keycard: L{flumotion.common.keycards.Keycard} 36 """ 37 return self.comp.authenticate(keycard)
38
39 - def remote_keepAlive(self, issuerName, ttl):
40 """ 41 Resets the expiry timeout for keycards issued by issuerName. 42 43 @param issuerName: the issuer for which keycards should be kept 44 alive; that is to say, keycards with the 45 attribute 'issuerName' set to this value will 46 have their ttl values reset. 47 @type issuerName: str 48 @param ttl: the new expiry timeout 49 @type ttl: number 50 """ 51 return self.comp.keepAlive(issuerName, ttl)
52
53 - def remote_removeKeycardId(self, keycardId):
54 try: 55 self.comp.removeKeycardId(keycardId) 56 # FIXME: at least have an exception name please 57 except KeyError: 58 self.warning('Could not remove keycard id %s' % keycardId)
59
60 - def remote_expireKeycardId(self, keycardId):
61 """ 62 Called by bouncer views to expire keycards. 63 """ 64 return self.comp.expireKeycardId(keycardId)
65
66 - def remote_setEnabled(self, enabled):
67 return self.comp.setEnabled(enabled)
68 69 70 BOUNCER_SOCKET = 'flumotion.component.bouncers.plug.BouncerPlug' 71 72
73 -class Bouncer(component.BaseComponent):
74 """ 75 I am the base class for all bouncers. 76 """ 77 componentMediumClass = BouncerMedium 78 logCategory = 'bouncer' 79
80 - def init(self):
81 self.plug = None
82
83 - def do_setup(self):
84 assert len(self.plugs[BOUNCER_SOCKET]) == 1 85 self.plug = self.plugs[BOUNCER_SOCKET][0]
86
87 - def setMedium(self, medium):
90
91 - def authenticate(self, keycard):
92 return self.plug.authenticate(keycard)
93
94 - def setEnabled(self, enabled):
95 self.plug.setEnabled(enabled)
96
97 - def hasKeycard(self, keycard):
98 return self.plug.hasKeycard(keycard)
99
100 - def removeKeycard(self, keycard):
102
103 - def removeKeycardId(self, id):
105
106 - def keepAlive(self, issuerName, ttl):
107 self.plug.keepAlive(issuerName, ttl)
108