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


Python AuthEncoding.pw_encrypt方法代码示例

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


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

示例1: doChangeUser

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
    def doChangeUser(self, principal_id, password):
        """
        Update user's password date and store passwords history.
        """
        user = api.user.get(username=principal_id)
        portal = api.portal.get()
        current_time = portal.ZopeTime()
        user.setMemberProperties({'password_date': current_time})
        self._invalidatePrincipalCache(principal_id)

        # Remember passwords here
        max_history_pws = api.portal.get_registry_record(
            'collective.pwexpiry.password_history_size'
        )

        if max_history_pws == 0:
            # disabled, return here.
            return

        enc_pw = password
        if not AuthEncoding.is_encrypted(enc_pw):
            enc_pw = AuthEncoding.pw_encrypt(enc_pw)

        pw_history = list(user.getProperty('password_history', tuple()))
        pw_history.append(enc_pw)
        if len(pw_history) > max_history_pws:
            # Truncate the history
            pw_history = pw_history[-max_history_pws:]

        user.setMemberProperties({'password_history': tuple(pw_history)})
开发者ID:sixfeetup,项目名称:collective.pwexpiry,代码行数:32,代码来源:pwexpiry_plugin.py

示例2: _createLDAPPassword

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
def _createLDAPPassword(password, encoding='SHA'):
    """ Create a password string suitable for the userPassword attribute
    """
    encoding = encoding.upper()

    if encoding in ('SSHA', 'SHA', 'CRYPT'):
        pwd_str = AuthEncoding.pw_encrypt(password, encoding)
    elif encoding == 'MD5':
        m = md5_new(password)
        pwd_str = '{MD5}' + base64.encodestring(m.digest())
    elif encoding == 'CLEAR':
        pwd_str = password
    else:
        pwd_str = AuthEncoding.pw_encrypt(password, 'SSHA')

    return pwd_str.strip()
开发者ID:eleddy,项目名称:Products.LDAPUserFolder,代码行数:18,代码来源:utils.py

示例3: setPasswordForUser

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
 def setPasswordForUser(self, login, password):
     """Add password to the list of previously used passwords for a user.
     """
     hashes = self._user_passwords.get(login, [])
     hash = AuthEncoding.pw_encrypt(password)
     hashes.append(hash)
     self._user_passwords[login] = hashes
     log.info("Password '%s' for user '%s' stored" % (password, login))
开发者ID:Covantec,项目名称:collective.passwordhistory,代码行数:10,代码来源:storage.py

示例4: password

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
 def password(self, password):
     # When editing, the password field is empty in the browser; do
     # not do anything then.
     if password is not None:
         self.context.password = AuthEncoding.pw_encrypt(
             safe_encode(password),
             encoding='BCRYPT'
         )
开发者ID:collective,项目名称:dexterity.membrane,代码行数:10,代码来源:password.py

示例5: updateUserPassword

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
    def updateUserPassword( self, user_id, password ):

        if self._user_passwords.get( user_id ) is None:
            raise KeyError, 'Invalid user ID: %s' % user_id

        if password:
            digested = AuthEncoding.pw_encrypt( password )
            self._user_passwords[ user_id ] = digested
开发者ID:goschtl,项目名称:zope,代码行数:10,代码来源:ZODBUserManager.py

示例6: testBlankPassword

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
 def testBlankPassword(self):
     pw = ''
     for id in AuthEncoding.listSchemes():
         enc = AuthEncoding.pw_encrypt(pw, id)
         assert enc != pw
         assert AuthEncoding.pw_validate(enc, pw)
         assert not AuthEncoding.pw_validate(enc, enc)
         assert not AuthEncoding.pw_validate(enc, 'xxx')
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:10,代码来源:testPasswordDigest.py

示例7: testGoodPassword

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
 def testGoodPassword(self):
     pw = 'good_password'
     assert len(AuthEncoding.listSchemes()) > 0  # At least one must exist!
     for id in AuthEncoding.listSchemes():
         enc = AuthEncoding.pw_encrypt(pw, id)
         assert enc != pw
         assert AuthEncoding.pw_validate(enc, pw)
         assert AuthEncoding.is_encrypted(enc)
         assert not AuthEncoding.is_encrypted(pw)
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:11,代码来源:testPasswordDigest.py

示例8: _pw_encrypt

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
    def _pw_encrypt(self, password):
        """Returns the AuthEncoding encrypted password

        If 'password' is already encrypted, it is returned
        as is and not encrypted again.
        """
        if AuthEncoding.is_encrypted(password):
            return password
        return AuthEncoding.pw_encrypt(password)
开发者ID:plone,项目名称:Products.PluggableAuthService,代码行数:11,代码来源:ZODBUserManager.py

示例9: addUser

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
    def addUser( self, user_id, login_name, password ):

        if self._user_passwords.get( user_id ) is not None:
            raise KeyError, 'Duplicate user ID: %s' % user_id

        if self._login_to_userid.get( login_name ) is not None:
            raise KeyError, 'Duplicate login name: %s' % login_name

        self._user_passwords[ user_id ] = AuthEncoding.pw_encrypt( password )
        self._login_to_userid[ login_name ] = user_id
        self._userid_to_login[ user_id ] = login_name
开发者ID:goschtl,项目名称:zope,代码行数:13,代码来源:ZODBUserManager.py

示例10: testBadPasword

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
 def testBadPasword(self):
     pw = 'OK_pa55w0rd \n'
     for id in AuthEncoding.listSchemes():
         enc = AuthEncoding.pw_encrypt(pw, id)
         assert enc != pw
         assert not AuthEncoding.pw_validate(enc, 'xxx')
         assert not AuthEncoding.pw_validate(enc, enc)
         if id != 'CRYPT':
             # crypt truncates passwords and would fail this test.
             assert not AuthEncoding.pw_validate(enc, pw[:-1])
         assert not AuthEncoding.pw_validate(enc, pw[1:])
         assert AuthEncoding.pw_validate(enc, pw)
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:14,代码来源:testPasswordDigest.py

示例11: testLongPassword

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
 def testLongPassword(self):
     pw = 'Pw' * 2000
     for id in AuthEncoding.listSchemes():
         enc = AuthEncoding.pw_encrypt(pw, id)
         assert enc != pw
         assert AuthEncoding.pw_validate(enc, pw)
         assert not AuthEncoding.pw_validate(enc, enc)
         assert not AuthEncoding.pw_validate(enc, 'xxx')
         if id != 'CRYPT':
             # crypt truncates passwords and would fail these tests.
             assert not AuthEncoding.pw_validate(enc, pw[:-2])
             assert not AuthEncoding.pw_validate(enc, pw[2:])
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:14,代码来源:testPasswordDigest.py

示例12: setAttempt

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
    def setAttempt(self, login, password):
        "increment attempt count and record date stamp last attempt and IP"

        root = self.getRootPlugin()
        count, last, IP, reference = root._login_attempts.get(login, (0, None, '', None))

        if reference and AuthEncoding.pw_validate(reference, password):
            return  # we don't count repeating same password in case its correct
        else:
            count += 1
        IP = self.remote_ip()
        log.info("user '%s' attempt #%i %s last: %s", login, count, IP, last)
        last = DateTime()
        reference = AuthEncoding.pw_encrypt(password)
        root._login_attempts[login] = (count, last, IP, reference)
开发者ID:fourdigits,项目名称:Products.LoginLockout,代码行数:17,代码来源:plugin.py

示例13: updateUserPassword

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
    def updateUserPassword( self, user_id, login_name, password ):

        if self._user_passwords.get( user_id ) is None:
            raise KeyError, 'Invalid user ID: %s' % user_id

        old_login_name = self._userid_to_login[ user_id ]

        if old_login_name != login_name:
            del self._login_to_userid[ old_login_name ]
            self._login_to_userid[ login_name ] = user_id
            self._userid_to_login[ user_id ] = login_name

        if password:
            digested = AuthEncoding.pw_encrypt( password )
            self._user_passwords[ user_id ] = digested
开发者ID:goschtl,项目名称:zope,代码行数:17,代码来源:ZODBUserManager.py

示例14: addUser

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
    def addUser( self, user_id, login_name, password ):

        if self._user_passwords.get( user_id ) is not None:
            raise KeyError, 'Duplicate user ID: %s' % user_id

        if self._login_to_userid.get( login_name ) is not None:
            raise KeyError, 'Duplicate login name: %s' % login_name

        self._user_passwords[ user_id ] = AuthEncoding.pw_encrypt( password )
        self._login_to_userid[ login_name ] = user_id
        self._userid_to_login[ user_id ] = login_name

        # enumerateUsers return value has changed
        view_name = createViewName('enumerateUsers')
        self.ZCacheable_invalidate(view_name=view_name)
开发者ID:goschtl,项目名称:zope,代码行数:17,代码来源:ZODBUserManager.py

示例15: testLongPassword

# 需要导入模块: from AccessControl import AuthEncoding [as 别名]
# 或者: from AccessControl.AuthEncoding import pw_encrypt [as 别名]
 def testLongPassword(self):
     pw = 'Pw' * 2000
     for id in AuthEncoding.listSchemes():
         enc = AuthEncoding.pw_encrypt(pw, id)
         assert enc != pw
         assert AuthEncoding.pw_validate(enc, pw)
         assert not AuthEncoding.pw_validate(enc, enc)
         assert not AuthEncoding.pw_validate(enc, 'xxx')
         if id not in ('CRYPT', 'BCRYPT'):
             # crypt truncates passwords and would fail these tests.
             # bcrypt works with password inputs where len(pw) <= 50
             assert not AuthEncoding.pw_validate(enc, pw[:-2]), (
                 '%r Failed: %s %s' % (id, enc, pw[:-2])
             )
             assert not AuthEncoding.pw_validate(enc, pw[2:])
开发者ID:netsight,项目名称:AccessControl,代码行数:17,代码来源:testPasswordDigest.py


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