# Path: openid/store/nonce.py
# NONCE_CHARS = string.ascii_letters + string.digits
# SKEW = 60 * 60 * 5
# def split(nonce_string):
# def checkTimestamp(nonce_string, allowed_skew=SKEW, now=None):
# def make_nonce_salt(length=6):
# def mkNonce(when=None):


import copy
import time
import six
from openid.store import nonce
    def storeAssociation(self, server_url, assoc):
        assocs = self._getServerAssocs(server_url)
        assocs.set(copy.deepcopy(assoc))

    def getAssociation(self, server_url, handle=None):
        assocs = self._getServerAssocs(server_url)
        if handle is None:
            return assocs.best()
        else:
            return assocs.get(handle)

    def removeAssociation(self, server_url, handle):
        assocs = self._getServerAssocs(server_url)
        return assocs.remove(handle)

    def useNonce(self, server_url, timestamp, salt):
        if abs(timestamp - time.time()) > nonce.SKEW:
            return False

        anonce = (six.text_type(server_url), int(timestamp), six.text_type(salt))
        if anonce in self.nonces:
            return False
        else:
            self.nonces[anonce] = None
            return True

    def cleanupNonces(self):
        now = time.time()
        expired = []
        for anonce in self.nonces:

# Path: openid/store/nonce.py
# NONCE_CHARS = string.ascii_letters + string.digits
# SKEW = 60 * 60 * 5
# def split(nonce_string):
# def checkTimestamp(nonce_string, allowed_skew=SKEW, now=None):
# def make_nonce_salt(length=6):
# def mkNonce(when=None):


# Path: openid/store/memstore.py
import copy
import time
import six
from openid.store import nonce

    def storeAssociation(self, server_url, assoc):
        assocs = self._getServerAssocs(server_url)
        assocs.set(copy.deepcopy(assoc))

    def getAssociation(self, server_url, handle=None):
        assocs = self._getServerAssocs(server_url)
        if handle is None:
            return assocs.best()
        else:
            return assocs.get(handle)

    def removeAssociation(self, server_url, handle):
        assocs = self._getServerAssocs(server_url)
        return assocs.remove(handle)

    def useNonce(self, server_url, timestamp, salt):
        if abs(timestamp - time.time()) > nonce.SKEW:
            return False

        anonce = (six.text_type(server_url), int(timestamp), six.text_type(salt))
        if anonce in self.nonces:
            return False
        else:
            self.nonces[anonce] = None
            return True

    def cleanupNonces(self):
        now = time.time()
        expired = []
        for anonce in self.nonces:

            if abs(anonce[1] - now) > nonce.SKEW: