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   
 23  from flumotion.component import component 
 24   
 25   
 26  __all__ = ['Bouncer'] 
 27   
 28   
29 -class BouncerMedium(component.BaseComponentMedium):
30 31 logCategory = 'bouncermedium'
32 - def remote_authenticate(self, keycard):
33 """ 34 Authenticates the given keycard. 35 36 @type keycard: L{flumotion.common.keycards.Keycard} 37 """ 38 return self.comp.authenticate(keycard)
39
40 - def remote_keepAlive(self, issuerName, ttl):
41 """ 42 Resets the expiry timeout for keycards issued by issuerName. 43 44 @param issuerName: the issuer for which keycards should be kept 45 alive; that is to say, keycards with the 46 attribute 'issuerName' set to this value will 47 have their ttl values reset. 48 @type issuerName: str 49 @param ttl: the new expiry timeout 50 @type ttl: number 51 """ 52 return self.comp.keepAlive(issuerName, ttl)
53
54 - def remote_removeKeycardId(self, keycardId):
55 try: 56 self.comp.removeKeycardId(keycardId) 57 # FIXME: at least have an exception name please 58 except KeyError: 59 self.warning('Could not remove keycard id %s' % keycardId)
60
61 - def remote_expireKeycardId(self, keycardId):
62 """ 63 Called by bouncer views to expire keycards. 64 """ 65 return self.comp.expireKeycardId(keycardId)
66
67 - def remote_setEnabled(self, enabled):
68 return self.comp.setEnabled(enabled)
69 70 71 BOUNCER_SOCKET = 'flumotion.component.bouncers.plug.BouncerPlug' 72 73
74 -class Bouncer(component.BaseComponent):
75 """ 76 I am the base class for all bouncers. 77 """ 78 componentMediumClass = BouncerMedium 79 logCategory = 'bouncer' 80
81 - def init(self):
82 self.plug = None
83
84 - def do_setup(self):
85 assert len(self.plugs[BOUNCER_SOCKET]) == 1 86 self.plug = self.plugs[BOUNCER_SOCKET][0]
87
88 - def setMedium(self, medium):
91
92 - def authenticate(self, keycard):
93 return self.plug.authenticate(keycard)
94
95 - def setEnabled(self, enabled):
96 self.plug.setEnabled(enabled)
97
98 - def hasKeycard(self, keycard):
99 return self.plug.hasKeycard(keycard)
100
101 - def removeKeycard(self, keycard):
103
104 - def removeKeycardId(self, id):
105 self.plug.removeKeycardId(id)
106
107 - def keepAlive(self, issuerName, ttl):
108 self.plug.keepAlive(issuerName, ttl)
109