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