• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python crypto_utils.decrypt_password函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中reviewboard.scmtools.crypto_utils.decrypt_password函数的典型用法代码示例。如果您正苦于以下问题:Python decrypt_password函数的具体用法?Python decrypt_password怎么用?Python decrypt_password使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_authorize

    def test_authorize(self):
        """Testing CodebaseHQ.authorize"""
        hosting_account = self.create_hosting_account(data={})

        with self.setup_http_test(payload=b'{}',
                                  hosting_account=hosting_account,
                                  expected_http_calls=1) as ctx:
            self.assertFalse(ctx.service.is_authorized())

            ctx.service.authorize(
                username='myuser',
                password='mypass',
                credentials={
                    'domain': 'mydomain',
                    'api_key': 'abc123',
                })

        ctx.assertHTTPCall(
            0,
            url='https://api3.codebasehq.com/users/myuser/public_keys',
            username='mydomain/myuser',
            password='abc123',
            headers={
                'Accept': 'application/xml',
            })

        self.assertEqual(set(six.iterkeys(hosting_account.data)),
                         {'api_key', 'domain', 'password'})
        self.assertEqual(decrypt_password(hosting_account.data['api_key']),
                         'abc123')
        self.assertEqual(hosting_account.data['domain'], 'mydomain')
        self.assertEqual(decrypt_password(hosting_account.data['password']),
                         'mypass')
        self.assertTrue(ctx.service.is_authorized())
开发者ID:chipx86,项目名称:reviewboard,代码行数:34,代码来源:test_codebasehq.py


示例2: test_authorize

    def test_authorize(self):
        """Testing Unfuddle.authorize"""
        hosting_account = self.create_hosting_account(data={})

        with self.setup_http_test(payload=b'{}',
                                  hosting_account=hosting_account,
                                  expected_http_calls=1) as ctx:
            self.assertFalse(ctx.service.is_authorized())

            ctx.service.authorize(username='myuser',
                                  password='abc123',
                                  unfuddle_account_domain='mydomain')

        ctx.assertHTTPCall(
            0,
            url='https://mydomain.unfuddle.com/api/v1/account/',
            username='myuser',
            password='abc123',
            headers={
                'Accept': 'application/json',
            })

        self.assertIn('password', hosting_account.data)
        self.assertNotEqual(hosting_account.data['password'], 'abc123')
        self.assertEqual(decrypt_password(hosting_account.data['password']),
                         'abc123')
        self.assertTrue(ctx.service.is_authorized())
开发者ID:chipx86,项目名称:reviewboard,代码行数:27,代码来源:test_unfuddle.py


示例3: _get_password

    def _get_password(self):
        """Returns the password for the repository.

        If a password is stored and encrypted, it will be decrypted and
        returned.

        If the stored password is in plain-text, then it will be encrypted,
        stored in the database, and returned.
        """
        password = self.encrypted_password

        # NOTE: Due to a bug in 2.0.9, it was possible to get a string of
        #       "\tNone", indicating no password. We have to check for this.
        if not password or password == '\tNone':
            password = None
        elif password.startswith(self.ENCRYPTED_PASSWORD_PREFIX):
            password = password[len(self.ENCRYPTED_PASSWORD_PREFIX):]

            if password:
                password = decrypt_password(password)
            else:
                password = None
        else:
            # This is a plain-text password. Convert it.
            self.password = password
            self.save(update_fields=['encrypted_password'])

        return password
开发者ID:antrianis,项目名称:reviewboard,代码行数:28,代码来源:models.py


示例4: _get_api_version

    def _get_api_version(self, hosting_url):
        """Return the version of the API supported by the given server.

        This method will cache the result.

        Args:
            hosting_url (unicode):
                The URL of the GitLab server.

        Returns:
            unicode:
            The version of the API as a string.

            It is returned as a string because
            :py:func:`djblets.cache.backend.cache_memoize` does not work on
            integer results.
        """
        headers = {}

        if self.account.data and 'private_token' in self.account.data:
            headers[b'PRIVATE-TOKEN'] = decrypt_password(
                self.account.data['private_token'])

        return cache_memoize(
            'gitlab-api-version:%s' % hosting_url,
            expiration=3600,
            lookup_callable=lambda: self._try_api_versions(
                hosting_url,
                headers=headers,
                path='/projects?per_page=1',
            )[0])
开发者ID:darmhoo,项目名称:reviewboard,代码行数:31,代码来源:gitlab.py


示例5: test_decrypt_password

    def test_decrypt_password(self):
        """Testing decrypt_password"""
        # The encrypted value was made with PyCrypto, to help with
        # compatibility testing from older installs.
        encrypted = b'AjsUGevO3UiVH7iN3zO9vxvqr5X5ozuAbOUByTATsitkhsih1Zc='

        self.assertEqual(decrypt_password(encrypted), self.PLAIN_TEXT)
开发者ID:chipx86,项目名称:reviewboard,代码行数:7,代码来源:test_crypto_utils.py


示例6: _get_private_token

    def _get_private_token(self):
        """Return the private token used for authentication.

        Returns:
            unicode:
            The API token.
        """
        return decrypt_password(self.account.data['private_token'])
开发者ID:darmhoo,项目名称:reviewboard,代码行数:8,代码来源:gitlab.py


示例7: test_encrypt_password

 def test_encrypt_password(self):
     """Testing encrypt_password"""
     # The encrypted value will change every time, since the iv changes,
     # so we can't compare a direct value. Instead, we need to ensure that
     # we can decrypt what we encrypt.
     self.assertEqual(
         decrypt_password(encrypt_password(self.PLAIN_TEXT)),
         self.PLAIN_TEXT)
开发者ID:chipx86,项目名称:reviewboard,代码行数:8,代码来源:test_crypto_utils.py


示例8: test_decrypt_password_with_custom_key

    def test_decrypt_password_with_custom_key(self):
        """Testing decrypt_password with custom key"""
        # The encrypted value was made with PyCrypto, to help with
        # compatibility testing from older installs.
        encrypted = b'/pOO3VWHRXd1ZAeHZo8MBGQsNClD4lS7XK9WAydt8zW/ob+e63E='

        self.assertEqual(decrypt_password(encrypted, key=self.CUSTOM_KEY),
                         self.PLAIN_TEXT)
开发者ID:chipx86,项目名称:reviewboard,代码行数:8,代码来源:test_crypto_utils.py


示例9: test_encrypt_password_with_custom_key

    def test_encrypt_password_with_custom_key(self):
        """Testing encrypt_password with custom key"""
        # The encrypted value will change every time, since the iv changes,
        # so we can't compare a direct value. Instead, we need to ensure that
        # we can decrypt what we encrypt.
        encrypted = encrypt_password(self.PLAIN_TEXT, key=self.CUSTOM_KEY)

        self.assertEqual(decrypt_password(encrypted, key=self.CUSTOM_KEY),
                         self.PLAIN_TEXT)
开发者ID:chipx86,项目名称:reviewboard,代码行数:9,代码来源:test_crypto_utils.py


示例10: test_authorize

    def test_authorize(self):
        """Testing Codebase HQ authorization password storage"""
        account = self._get_hosting_account()
        service = account.service

        self.assertFalse(service.is_authorized())

        self._authorize(service)

        self.assertIn('api_key', account.data)
        self.assertIn('domain', account.data)
        self.assertIn('password', account.data)
        self.assertEqual(decrypt_password(account.data['api_key']),
                         'abc123')
        self.assertEqual(account.data['domain'], 'mydomain')
        self.assertEqual(decrypt_password(account.data['password']),
                         'mypass')
        self.assertTrue(service.is_authorized())
开发者ID:davidt,项目名称:reviewboard,代码行数:18,代码来源:test_codebasehq.py


示例11: api_get

    def api_get(self, url, username=None, password=None, json=True, *args,
                **kwargs):
        """Make a request to the API and return the result.

        Args:
            url (unicode):
                The URL to make the request against.

            username (unicode, optional):
                The username to use when making the request. If not provided,
                the account username will be used.

                This argument must be passed when authorizing.

            password (unicode, optional):
                The password to use when making the request. If not provided,
                the account password will be used.

                This argument must be passed when authorizing.

            json (bool, optional):
                Whether or not to interpret the response as JSON. Defaults to
                ``True``.

            *args (tuple):
                Additional positional arguments to pass to the HTTP request
                method.

            **kwargs (dict):
                Additional keyword arguments to pass to the HTTP request
                method.

        Returns:
            object:
            One of the following:

            * If ``json`` is ``True``, the parsed response (:py:class:`dict`).
            * Otherwise, the raw response (:py:class:`unicode`).
        """
        if json:
            method = self.json_get
        else:
            method = self.http_get

        if username is None or password is None:
            username = self.account.username
            password = decrypt_password(
                self.account.data['gerrit_http_password'])

        return method(
            url,
            username=username,
            password=password,
            *args,
            **kwargs
        )[0]
开发者ID:chipx86,项目名称:reviewboard,代码行数:56,代码来源:gerrit.py


示例12: get_password

    def get_password(self):
        """Return the password for this account.

        This is needed for Perforce and Subversion.

        Returns:
            unicode:
            The stored password for the account.
        """
        return decrypt_password(self.account.data['password'])
开发者ID:chipx86,项目名称:reviewboard,代码行数:10,代码来源:assembla.py


示例13: api_get

    def api_get(self, url, raw_content=False):
        """Perform an HTTP GET request to the API.

        Args:
            url (unicode):
                The full URL to the API resource.

            raw_content (bool, optional):
                If set to ``True``, the raw content of the result will be
                returned, instead of a parsed XML result.

        Returns:
            object:
            The parsed content of the result, as a dictionary, or the raw
            bytes content if ``raw_content`` is ``True``.
        """
        hosting_service = self.hosting_service

        try:
            account_data = hosting_service.account.data
            api_username = '%s/%s' % (account_data['domain'],
                                      hosting_service.account.username)
            api_key = decrypt_password(account_data['api_key'])

            response = self.http_get(
                url,
                username=api_username,
                password=api_key,
                headers={
                    'Accept': self.API_MIMETYPE,
                })
            data = response.data

            if raw_content:
                return data
            else:
                return self.parse_xml(data)
        except HTTPError as e:
            data = e.read()
            msg = six.text_type(e)

            rsp = self.parse_xml(data)

            if rsp and 'errors' in rsp:
                errors = rsp['errors']

                if 'error' in errors:
                    msg = errors['error']

            if e.code == 401:
                raise AuthorizationError(msg)
            else:
                raise HostingServiceAPIError(msg, http_code=e.code, rsp=rsp)
        except URLError as e:
            raise HostingServiceAPIError(e.reason)
开发者ID:chipx86,项目名称:reviewboard,代码行数:55,代码来源:codebasehq.py


示例14: api_get

    def api_get(self, url, raw_content=False):
        try:
            response = self.client.http_get(
                url,
                username=self.account.username,
                password=decrypt_password(self.account.data['password']))

            if raw_content:
                return response.data
            else:
                return response.json
        except HTTPError as e:
            self._check_api_error(e)
开发者ID:chipx86,项目名称:reviewboard,代码行数:13,代码来源:bitbucket.py


示例15: _api_get

    def _api_get(self, url, raw_content=False):
        try:
            data, headers = self.client.http_get(
                url,
                username=self.account.username,
                password=decrypt_password(self.account.data['password']))

            if raw_content:
                return data
            else:
                return json.loads(data)
        except HTTPError as e:
            self._check_api_error(e)
开发者ID:Hackthings,项目名称:reviewboard,代码行数:13,代码来源:bitbucket.py


示例16: test_authorize

    def test_authorize(self):
        """Testing Beanstalk.authorize"""
        account = self.create_hosting_account(data={})
        service = account.service

        self.assertFalse(service.is_authorized())

        service.authorize('myuser', 'abc123', None)

        self.assertIn('password', account.data)
        self.assertNotEqual(account.data['password'], 'abc123')
        self.assertEqual(decrypt_password(account.data['password']), 'abc123')
        self.assertTrue(service.is_authorized())
开发者ID:chipx86,项目名称:reviewboard,代码行数:13,代码来源:test_beanstalk.py


示例17: get_password

    def get_password(self):
        """Return the password for this account.

        This is used primarily for Subversion repositories, so that direct
        access can be performed in order to fetch properties and other
        information.

        This does not return the API key.

        Returns:
            unicode:
            The account password for repository access.
        """
        return decrypt_password(self.account.data['password'])
开发者ID:chipx86,项目名称:reviewboard,代码行数:14,代码来源:codebasehq.py


示例18: _api_get

    def _api_get(self, url, raw_content=False):
        try:
            data, headers = self._http_get(
                url, username=self.account.username, password=decrypt_password(self.account.data["password"])
            )

            if raw_content:
                return data
            else:
                return simplejson.loads(data)
        except HTTPError, e:
            # Bitbucket's API documentation doesn't provide any information
            # on an error structure, and the API browser shows that we
            # sometimes get a raw error string, and sometimes raw HTML.
            # We'll just have to return what we get for now.
            raise Exception(e.read())
开发者ID:harrifeng,项目名称:reviewboard,代码行数:16,代码来源:bitbucket.py


示例19: get_user_api_token

def get_user_api_token(user):
    """Return the user's API token for I Done This.

    Args:
        user (django.contrib.auth.models.User):
            The user whose API token should be retrieved.

    Returns:
        unicode:
        The user's API token, or ``None`` if the user has not set one.
    """
    try:
        settings = user.get_profile().settings['idonethis']
        return decrypt_password(settings['api_token'])
    except KeyError:
        return None
开发者ID:reviewboard,项目名称:rbintegrations,代码行数:16,代码来源:utils.py


示例20: _api_get

    def _api_get(self, url, raw_content=False):
        try:
            data, headers = self._http_get(
                url, username=self.account.username, password=decrypt_password(self.account.data["password"])
            )

            if raw_content:
                return data
            else:
                return json.loads(data)
        except HTTPError as e:
            data = e.read()

            try:
                rsp = json.loads(data)
            except:
                rsp = None

            if rsp and "errors" in rsp:
                raise Exception("; ".join(rsp["errors"]))
            else:
                raise Exception(six.text_type(e))
开发者ID:rajasaur,项目名称:reviewboard,代码行数:22,代码来源:beanstalk.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python crypto_utils.encrypt_password函数代码示例发布时间:2022-05-26
下一篇:
Python core.SCMTool类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap