1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import time
19
20 from flumotion.component.plugs import base
21
22 __all__ = ['BouncerPlug']
23 __version__ = "$Rev$"
24
25
27 """
28 I am the base class for all bouncer plugs.
29 """
30 logCategory = 'bouncer-plug'
31
32 - def start(self, component):
37
39 raise NotImplementedError("Subclass does not override authenticate")
40
43
45
46
47 keycardId = self._idFormat % self._idCounter
48 self._idCounter += 1
49 return keycardId
50
52 """
53 Adds a keycard to the keycards store.
54 Can be called with the same keycard more than one time.
55 If the keycard has already been added successfully,
56 adding it again will succeed and return True.
57
58 @param keycard: the keycard to add.
59 @return: if the plug accepts the keycard.
60 """
61
62 if keycard.id in self._keycards:
63 self.debug("%r in %r", keycard.id, self._keycards)
64
65 return True
66
67 keycardId = self.generateKeycardId()
68 keycard.id = keycardId
69
70 if hasattr(keycard, 'ttl') and keycard.ttl <= 0:
71 self.debug("no ttlz")
72 self.log('immediately expiring keycard %r', keycard)
73 return False
74
75 self._addKeycard(keycard)
76 return True
77
88
93
98
100 self.log("expiring keycard with id %r", keycardId)
101 self.expire((keycardId, ))
102
104 self.log("expiring keycards with ids %r", keycardIds)
105 self.expire(keycardIds)
106
108 """
109 Override to update sub-class specific data related to keycards.
110 Called when the base bouncer accepts and references a new keycard.
111 """
112
114 """
115 Override to cleanup sub-class specific data related to keycards.
116 Called when the base bouncer has cleanup his references to a keycard.
117 """
118
119
125