Trees | Indices | Help |
---|
|
1 # -*- Mode: Python; test-case-name: flumotion.test.test_keycards -*- 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 serializable keycards used for authentication inside Flumotion 24 """ 25 26 from twisted.cred import credentials as tcredentials 27 from twisted.spread import pb 28 29 from flumotion.twisted import credentials 30 from flumotion.twisted.compat import implements 31 from flumotion.common import common 32 33 # state enum values 34 REFUSED = 0 35 REQUESTING = 1 36 AUTHENTICATED = 2 37 _statesEnum=['REFUSED', 'REQUESTING', 'AUTHENTICATED'] 3840 """ 41 I am the base class for keycards which together with credentials are 42 a serializable object used in authentication inside Flumotion. 43 """ 44 implements(common.mergeImplements(pb.Copyable, pb.RemoteCopy) + (tcredentials.ICredentials, ))79 82 83 pb.setUnjellyableForClass(KeycardGeneric, KeycardGeneric) 84 # class KeycardUACCP: username, address, crypt password 85 # from UsernameCryptPasswordCrypt 86 87 UCPP = credentials.UsernameCryptPasswordPlaintext46 self.bouncerName = None # set by requester,decides which bouncer 47 self.requesterId = None # who is requesting auth ? 48 self.avatarId = None # avatarId prefered by requester 49 self.id = None # set by bouncer when authenticated 50 self.duration = 0 # means unlimited 51 self.domain = None # requester can pass this to bouncer 52 self.state = REQUESTING5355 """ 56 Set the domain of the requester on the keycard. 57 58 @type domain: string 59 """ 60 self.domain = domain6163 """ 64 Return a dictionary of the viewable data on the keycard that can be 65 used to identify the keycard. 66 It doesn't include sensitive information though. 67 68 Subclasses should override to add additional information. 69 """ 70 return { 71 'id': self.id, 72 'requester': self.requesterId, 73 'domain': self.domain 74 }7577 return "<%s for requesterId %r in state %s>" % (self.__class__.__name__, 78 self.requesterId, _statesEnum[self.state])89 """ 90 I am a keycard with a username, plaintext password and IP address. 91 I get authenticated against a crypt password. 92 """ 93 implements(common.mergeImplements(Keycard, UCPP)) 98109 110 pb.setUnjellyableForClass(KeycardUACPP, KeycardUACPP) 111 112 #: username, address, crypt password 113 # from UsernameCryptPasswordCrypt 114 115 UCPCC = credentials.UsernameCryptPasswordCryptChallenger100 d = Keycard.getData(self) 101 d['username'] = self.username 102 d['address'] = self.address 103 return d104106 return "<%s %s@%s for requesterId %r in state %s>" % ( 107 self.__class__.__name__, self.username, self.address, 108 self.requesterId, _statesEnum[self.state])117 """ 118 I am a keycard with a username and IP address. 119 I get authenticated through challenge/response on a crypt password. 120 """ 121 implements(common.mergeImplements(Keycard, UCPCC)) 126137 138 pb.setUnjellyableForClass(KeycardUACPCC, KeycardUACPCC) 139128 d = Keycard.getData(self) 129 d['username'] = self.username 130 d['address'] = self.address 131 return d132134 return "<%s %s@%s for requesterId %r in state %s>" % ( 135 self.__class__.__name__, self.username, self.address, 136 self.requesterId, _statesEnum[self.state])141 """ 142 I am a keycard with a token and IP address. 143 I get authenticated by token and maybe IP address. 144 """ 145 implements(common.mergeImplements(Keycard,credentials.Token)) 146 151162 163 pb.setUnjellyableForClass(KeycardToken, KeycardToken) 164 165 USPCC = credentials.UsernameSha256PasswordCryptChallenger153 d = Keycard.getData(self) 154 d['token'] = self.token 155 d['address'] = self.address 156 return d157159 return "<%s token %s @%s for requesterId %r in state %s>" % ( 160 self.__class__.__name__, self.token, self.address, 161 self.requesterId, _statesEnum[self.state])167 """ 168 I am a keycard with a username and IP address. 169 I get authenticated through challenge/response on a SHA-256 password. 170 """ 171 implements(common.mergeImplements(Keycard, USPCC)) 176187 188 pb.setUnjellyableForClass(KeycardUASPCC, KeycardUASPCC) 189178 d = Keycard.getData(self) 179 d['username'] = self.username 180 d['address'] = self.address 181 return d182184 return "<%s %s@%s for requesterId %r in state %s>" % ( 185 self.__class__.__name__, self.username, self.address, 186 self.requesterId, _statesEnum[self.state])
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Apr 11 07:40:29 2008 | http://epydoc.sourceforge.net |