# Path: restkit/util.py
# def to_bytestring(s):
#     if not isinstance(s, basestring):
#         raise TypeError("value should be a str or unicode")
# 
#     if isinstance(s, unicode):
#         return s.encode('utf-8')
#     return s
# 
# Path: restkit/version.py



import base64
import urllib
import time
import random
import urlparse
import hmac
import binascii
    import sha
    from urlparse import parse_qs, parse_qsl
    from cgi import parse_qs, parse_qsl
from restkit.util import to_bytestring
    from hashlib import sha1
from restkit.version import __version__
        signing and the message to be signed. The latter may be used in error
        messages to help clients debug their software.

        """
        raise NotImplementedError

    def sign(self, request, consumer, token):
        """Returns the signature for the given request, based on the consumer
        and token also provided.

        You should use your implementation of `signing_base()` to build the
        message to sign. Otherwise it may be less useful for debugging.

        """
        raise NotImplementedError

    def check(self, request, consumer, token, signature):
        """Returns whether the given signature is the correct signature for
        the given consumer and token signing the given request."""
        built = self.sign(request, consumer, token)
        return built == signature


class SignatureMethod_HMAC_SHA1(SignatureMethod):
    name = 'HMAC-SHA1'

    def signing_base(self, request, consumer, token):
        if not hasattr(request, 'normalized_url') or request.normalized_url is None:
            raise ValueError("Base URL for request is not set.")


# Path: restkit/util.py
# def to_bytestring(s):
#     if not isinstance(s, basestring):
#         raise TypeError("value should be a str or unicode")
# 
#     if isinstance(s, unicode):
#         return s.encode('utf-8')
#     return s
# 
# Path: restkit/version.py



# Path: restkit/oauth2.py
import base64
import urllib
import time
import random
import urlparse
import hmac
import binascii
    import sha
    from urlparse import parse_qs, parse_qsl
    from cgi import parse_qs, parse_qsl
from restkit.util import to_bytestring
    from hashlib import sha1
from restkit.version import __version__

        signing and the message to be signed. The latter may be used in error
        messages to help clients debug their software.

        """
        raise NotImplementedError

    def sign(self, request, consumer, token):
        """Returns the signature for the given request, based on the consumer
        and token also provided.

        You should use your implementation of `signing_base()` to build the
        message to sign. Otherwise it may be less useful for debugging.

        """
        raise NotImplementedError

    def check(self, request, consumer, token, signature):
        """Returns whether the given signature is the correct signature for
        the given consumer and token signing the given request."""
        built = self.sign(request, consumer, token)
        return built == signature


class SignatureMethod_HMAC_SHA1(SignatureMethod):
    name = 'HMAC-SHA1'

    def signing_base(self, request, consumer, token):
        if not hasattr(request, 'normalized_url') or request.normalized_url is None:
            raise ValueError("Base URL for request is not set.")


        sig = (