Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
AbstractDigestAuthHandler Class Reference
Inheritance diagram for AbstractDigestAuthHandler:
HTTPDigestAuthHandler ProxyDigestAuthHandler

Public Member Functions

def __init__
 
def http_error_auth_reqed
 
def retry_http_digest_auth
 
def get_authorization
 
def get_algorithm_impls
 
def get_entity_digest
 

Data Fields

 passwd
 
 add_password
 

Detailed Description

Definition at line 624 of file urllib2.py.

Constructor & Destructor Documentation

def __init__ (   self,
  passwd = None 
)

Definition at line 626 of file urllib2.py.

627  def __init__(self, passwd=None):
628  if passwd is None:
629  passwd = HTTPPasswordMgr()
630  self.passwd = passwd
631  self.add_password = self.passwd.add_password

Member Function Documentation

def get_algorithm_impls (   self,
  algorithm 
)

Definition at line 695 of file urllib2.py.

References hmac.digest(), and imaplib.e.

696  def get_algorithm_impls(self, algorithm):
697  # lambdas assume digest modules are imported at the top level
698  if algorithm == 'MD5':
699  H = lambda x, e=encode_digest:e(md5.new(x).digest())
700  elif algorithm == 'SHA':
701  H = lambda x, e=encode_digest:e(sha.new(x).digest())
702  # XXX MD5-sess
703  KD = lambda s, d, H=H: H("%s:%s" % (s, d))
704  return H, KD
def get_authorization (   self,
  req,
  chal 
)

Definition at line 651 of file urllib2.py.

References AbstractDigestAuthHandler.get_algorithm_impls(), and AbstractDigestAuthHandler.get_entity_digest().

652  def get_authorization(self, req, chal):
653  try:
654  realm = chal['realm']
655  nonce = chal['nonce']
656  algorithm = chal.get('algorithm', 'MD5')
657  # mod_digest doesn't send an opaque, even though it isn't
658  # supposed to be optional
659  opaque = chal.get('opaque', None)
660  except KeyError:
661  return None
662 
663  H, KD = self.get_algorithm_impls(algorithm)
664  if H is None:
665  return None
666 
667  user, pw = self.passwd.find_user_password(realm,
668  req.get_full_url())
669  if user is None:
670  return None
671 
672  # XXX not implemented yet
673  if req.has_data():
674  entdig = self.get_entity_digest(req.get_data(), chal)
675  else:
676  entdig = None
677 
678  A1 = "%s:%s:%s" % (user, realm, pw)
679  A2 = "%s:%s" % (req.has_data() and 'POST' or 'GET',
680  # XXX selector: what about proxies and full urls
681  req.get_selector())
682  respdig = KD(H(A1), "%s:%s" % (nonce, H(A2)))
683  # XXX should the partial digests be encoded too?
684 
685  base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' \
686  'response="%s"' % (user, realm, nonce, req.get_selector(),
687  respdig)
688  if opaque:
689  base = base + ', opaque="%s"' % opaque
690  if entdig:
691  base = base + ', digest="%s"' % entdig
692  if algorithm != 'MD5':
693  base = base + ', algorithm="%s"' % algorithm
694  return base
def get_entity_digest (   self,
  data,
  chal 
)

Definition at line 705 of file urllib2.py.

706  def get_entity_digest(self, data, chal):
707  # XXX not implemented yet
708  return None
709 
def http_error_auth_reqed (   self,
  authreq,
  host,
  req,
  headers 
)

Definition at line 632 of file urllib2.py.

References HTTPBasicAuthHandler.auth_header, ProxyBasicAuthHandler.auth_header, and AbstractDigestAuthHandler.retry_http_digest_auth().

633  def http_error_auth_reqed(self, authreq, host, req, headers):
634  authreq = headers.get(self.auth_header, None)
635  if authreq:
636  kind = authreq.split()[0]
637  if kind == 'Digest':
638  return self.retry_http_digest_auth(req, authreq)
def retry_http_digest_auth (   self,
  req,
  auth 
)

Definition at line 639 of file urllib2.py.

References HTTPBasicAuthHandler.auth_header, ProxyBasicAuthHandler.auth_header, AbstractDigestAuthHandler.get_authorization(), urllib2.parse_http_list(), and urllib2.parse_keqv_list().

640  def retry_http_digest_auth(self, req, auth):
641  token, challenge = auth.split(' ', 1)
642  chal = parse_keqv_list(parse_http_list(challenge))
643  auth = self.get_authorization(req, chal)
644  if auth:
645  auth_val = 'Digest %s' % auth
646  if req.headers.get(self.auth_header, None) == auth_val:
647  return None
648  req.add_header(self.auth_header, auth_val)
649  resp = self.parent.open(req)
650  return resp

Field Documentation

add_password

Definition at line 630 of file urllib2.py.

passwd

Definition at line 629 of file urllib2.py.


The documentation for this class was generated from the following file: