~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/auth/signer.py

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-01-21 11:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110121114806-v8fvnnl6az4m4ohv
Tags: upstream-2011.1~bzr597
ImportĀ upstreamĀ versionĀ 2011.1~bzr597

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
import base64
47
47
import hashlib
48
48
import hmac
49
 
import logging
50
49
import urllib
51
50
 
52
51
# NOTE(vish): for new boto
54
53
# NOTE(vish): for old boto
55
54
import boto.utils
56
55
 
 
56
from nova import log as logging
57
57
from nova.exception import Error
58
58
 
59
59
 
 
60
LOG = logging.getLogger('nova.signer')
 
61
 
 
62
 
60
63
class Signer(object):
61
64
    """Hacked up code from boto/connection.py"""
62
65
 
120
123
 
121
124
    def _calc_signature_2(self, params, verb, server_string, path):
122
125
        """Generate AWS signature version 2 string."""
123
 
        logging.debug('using _calc_signature_2')
 
126
        LOG.debug('using _calc_signature_2')
124
127
        string_to_sign = '%s\n%s\n%s\n' % (verb, server_string, path)
125
128
        if self.hmac_256:
126
129
            current_hmac = self.hmac_256
136
139
            val = urllib.quote(val, safe='-_~')
137
140
            pairs.append(urllib.quote(key, safe='') + '=' + val)
138
141
        qs = '&'.join(pairs)
139
 
        logging.debug('query string: %s', qs)
 
142
        LOG.debug('query string: %s', qs)
140
143
        string_to_sign += qs
141
 
        logging.debug('string_to_sign: %s', string_to_sign)
 
144
        LOG.debug('string_to_sign: %s', string_to_sign)
142
145
        current_hmac.update(string_to_sign)
143
146
        b64 = base64.b64encode(current_hmac.digest())
144
 
        logging.debug('len(b64)=%d', len(b64))
145
 
        logging.debug('base64 encoded digest: %s', b64)
 
147
        LOG.debug('len(b64)=%d', len(b64))
 
148
        LOG.debug('base64 encoded digest: %s', b64)
146
149
        return b64
147
150
 
148
151