def validator_from_rfc2617_digest(self, **keywords): authenticator = DigestRFC2617Authenticator file = PASSWD_FILE if keywords.has_key('_file_'): file = keywords['_file_'] name = authenticator.name(**keywords) nonce = authenticator.current_id(**keywords) current_key = authenticator.current_key(**keywords) self.__lock.acquire() try: if not self.__users.has_key(name): user = User(name, 0, file) user._authenticators = {} else: user = self.__users[name] authenticators = user._authenticators if not authenticators.has_key(current_key): pending = self.__pending[authenticator] if nonce in pending: pending.remove(nonce) authenticators[current_key] = authenticator( user, **keywords) authenticators[current_key].initiate_nonce(nonce) else: raise EAuthenticationFailed('Unknown nonce value.') self.__users[name] = user finally: self.__lock.release() return self.initialize_authenticator(authenticator, **keywords)
def get_user(self, name): users = self.__users if not users.has_key(name): user = User(name, 0, PASSWD_FILE) user._authenticators = {} users[name] = user return users[name]
def initialize_authenticator(self, authenticator, **keywords): name = authenticator.name(**keywords) file = PASSWD_FILE if keywords.has_key('_file_'): file = keywords['_file_'] users = self.__users self.__lock.acquire() try: if not users.has_key(name): try: user = User(name, 0, file) except EInvalidValue: raise EAuthenticationFailed() user._authenticators = {} users[name] = user validator = authenticator(users[name], **keywords) else: user = users[name] current_key = authenticator.current_key(**keywords) validator = authenticator(user, **keywords) validator.validate(**keywords) next_key = validator.next_key() users[name]._authenticators[next_key] = validator finally: self.__lock.release() return validator
def validator_from_rfc2617_digest(self, **keywords): authenticator = DigestRFC2617Authenticator file = PASSWD_FILE if keywords.has_key("_file_"): file = keywords["_file_"] name = authenticator.name(**keywords) nonce = authenticator.current_id(**keywords) current_key = authenticator.current_key(**keywords) self.__lock.acquire() try: if not self.__users.has_key(name): user = User(name, 0, file) user._authenticators = {} else: user = self.__users[name] authenticators = user._authenticators if not authenticators.has_key(current_key): pending = self.__pending[authenticator] if nonce in pending: pending.remove(nonce) authenticators[current_key] = authenticator(user, **keywords) authenticators[current_key].initiate_nonce(nonce) else: raise EAuthenticationFailed("Unknown nonce value.") self.__users[name] = user finally: self.__lock.release() return self.initialize_authenticator(authenticator, **keywords)
def initialize_authenticator(self, authenticator, **keywords): name = authenticator.name(**keywords) file = PASSWD_FILE if keywords.has_key("_file_"): file = keywords["_file_"] users = self.__users self.__lock.acquire() try: if not users.has_key(name): try: user = User(name, 0, file) except EInvalidValue: raise EAuthenticationFailed() user._authenticators = {} users[name] = user validator = authenticator(users[name], **keywords) else: user = users[name] current_key = authenticator.current_key(**keywords) validator = authenticator(user, **keywords) validator.validate(**keywords) next_key = validator.next_key() users[name]._authenticators[next_key] = validator finally: self.__lock.release() return validator
def has_user(self, name): users = self.__users if not users.has_key(name): try: user = User(name, 0, PASSWD_FILE) user._authenticators = {} users[name] = user except Exception: msglog.log("broadway", msglog.types.WARN, "User '%s' not found" % name) return False return users.has_key(name)