当前位置: 首页>>代码示例>>Python>>正文


Python Authentication.unwrapUserPassword方法代码示例

本文整理汇总了Python中Authentication.unwrapUserPassword方法的典型用法代码示例。如果您正苦于以下问题:Python Authentication.unwrapUserPassword方法的具体用法?Python Authentication.unwrapUserPassword怎么用?Python Authentication.unwrapUserPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Authentication的用法示例。


在下文中一共展示了Authentication.unwrapUserPassword方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: changePassword

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import unwrapUserPassword [as 别名]
 def changePassword(self, sid, safeOld, safeNew):
     session = self.sessions[sid]
     if not session:
         raise SecurityException('No such session id.')
     challenge = session.challenge
     account = self.accounts[session.login]
     oldPassword = Authentication.unwrapUserPassword(safeOld, challenge)
     newPassword = Authentication.unwrapUserPassword(safeNew, challenge)
     if not account.verifyPassword(oldPassword):
         raise SecurityException('Wrong login and/or password.')
     if len(newPassword) < ige.Const.ACCOUNT_PASSWD_MIN_LEN:
         raise SecurityException('Password is too short.')
     account.setPassword(newPassword)
     log.debug('Password of account {0} successfully changed.'.format(session.login))
     return None, None
开发者ID:ospaceteam,项目名称:outerspace,代码行数:17,代码来源:ClientMngr.py

示例2: createAccount

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import unwrapUserPassword [as 别名]
 def createAccount(self, sid, login, safePasswd, nick, email):
     log.message('Creating account', login, nick, email)
     session = self.getSession(sid)
     plainPassword = Authentication.unwrapUserPassword(safePasswd, session.challenge)
     login = login.strip()
     plainPassword = plainPassword.strip()
     nick = nick.strip()
     # check requirement
     if len(login) < ige.Const.ACCOUNT_LOGIN_MIN_LEN:
         raise SecurityException('Login is too short.')
     if len(plainPassword) < ige.Const.ACCOUNT_PASSWD_MIN_LEN:
         raise SecurityException('Password is too short.')
     if len(nick) < ige.Const.ACCOUNT_NICK_MIN_LEN:
         raise SecurityException('Nick is too short.')
     # check login, nick and uid
     for key in self.accounts.keys():
         account = self.accounts[key]
         if account.login == login:
             raise SecurityException('Login already used.')
         elif account.nick == nick:
             raise SecurityException('Nick already used.')
         elif account.email == email:
             raise SecurityException('E-mail already used.')
     # create account
     account = Account(login, nick, email, plainPassword)
     # update
     self.accounts.create(account, id = str(account.login))
     log.message('Account created, confirmation token:', account.confToken)
     # TODO send confirmation token to the email address
     return 1, None
开发者ID:ospaceteam,项目名称:outerspace,代码行数:32,代码来源:ClientMngr.py

示例3: login

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import unwrapUserPassword [as 别名]
 def login(self, sid, login, safePassword, hostID):
     login = login.strip()
     if not login:
         raise SecurityException("Specify login, please.")
     if login in ():
         raise SecurityException("Account blocked")
     log.debug(sid, 'login', repr(login), 'hostid', hostID)
     login = str(login)
     challenge = self.sessions[sid].challenge
     log.debug("Trying local login for user", login)
     if not self.accounts.has_key(login):
         raise SecurityException('Wrong login and/or password.')
     account = self.accounts[login]
     plainPassword = Authentication.unwrapUserPassword(safePassword, challenge)
     if not account.verifyPassword(plainPassword):
         raise SecurityException('Wrong login and/or password.')
     # setup session
     self.sessions[sid].setAttrs(account.login, account.nick, account.email)
     account.lastLogin = time.time()
     account.addHostID(hostID)
     return 1, None
开发者ID:ospaceteam,项目名称:outerspace,代码行数:23,代码来源:ClientMngr.py


注:本文中的Authentication.unwrapUserPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。