示例#1
0
 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)
示例#2
0
 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]
示例#3
0
 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
示例#4
0
 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)
示例#5
0
 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
示例#6
0
 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]
示例#7
0
 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)
示例#8
0
 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)