~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/cred/util.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- test-case-name: twisted.test.test_newcred -*-
 
2
# Copyright (c) 2001-2008 Twisted Matrix Laboratories.
 
3
# See LICENSE for details.
 
4
 
 
5
"""
 
6
Outdated, deprecated functionality related to challenge-based authentication.
 
7
 
 
8
Seek a solution to your problem elsewhere.  This module is deprecated.
 
9
"""
 
10
 
 
11
# System Imports
 
12
import random, warnings
 
13
 
 
14
from twisted.python.hashlib import md5
 
15
from twisted.cred.error import Unauthorized
 
16
 
 
17
 
 
18
def respond(challenge, password):
 
19
    """Respond to a challenge.
 
20
    This is useful for challenge/response authentication.
 
21
    """
 
22
    warnings.warn(
 
23
        "twisted.cred.util.respond is deprecated since Twisted 8.3.",
 
24
        category=PendingDeprecationWarning,
 
25
        stacklevel=2)
 
26
    m = md5()
 
27
    m.update(password)
 
28
    hashedPassword = m.digest()
 
29
    m = md5()
 
30
    m.update(hashedPassword)
 
31
    m.update(challenge)
 
32
    doubleHashedPassword = m.digest()
 
33
    return doubleHashedPassword
 
34
 
 
35
def challenge():
 
36
    """I return some random data.
 
37
    """
 
38
    warnings.warn(
 
39
        "twisted.cred.util.challenge is deprecated since Twisted 8.3.",
 
40
        category=PendingDeprecationWarning,
 
41
        stacklevel=2)
 
42
    crap = ''
 
43
    for x in range(random.randrange(15,25)):
 
44
        crap = crap + chr(random.randint(65,90))
 
45
    crap = md5(crap).digest()
 
46
    return crap