<commit_before>import BaseHTTPServer
from urlparse import urlparse
import time, random, Cookie

from openid.util import random_string, w3cdate, append_args
from openid.examples import util
from openid.errors import ProtocolError
from openid.server import OpenIDServer
from openid.interface import Request, response_page, redirect
from openid.association import ServerAssociation

addr = 'http://localhost:8082/'

class ConcreteServer(OpenIDServer):
    def __init__(self):
        OpenIDServer.__init__(self, random.SystemRandom())
        self.counter = 0
        self.assoc_store = {}
        self.trust_store = set()  # (identity, trust_root)

        self.secret_handle = None
        self.lifespan = 60 * 60 * 24 * 30 # 30 days

    def handle(self, req):
        # This is reimplemented in the subclass so that extra
        # debugging/tracing information can be extracted.  It isn't
        # necessary in the general case.
        print 'handling openid.mode=%r' % (req.get('openid.mode'),)
        return OpenIDServer.handle(self, req)

    def get_new_secret(self, assoc_type):
        tmpl = '{%s}%i/%i'
        if assoc_type == 'HMAC-SHA1':
            self.counter += 1

            secret = random_string(20, self.srand)
            assoc_handle = tmpl % (assoc_type, time.time(), self.counter)
            replace_after_offset = 60 * 60
            expiry_offset = replace_after_offset + 60 * 60

            assoc = ServerAssociation(
                assoc_handle, secret, expiry_offset, replace_after_offset)
<commit_msg>[project @ Fix bug in tracing code]<commit_after>import BaseHTTPServer
from urlparse import urlparse
import time, random, Cookie

from openid.util import random_string, w3cdate, append_args
from openid.examples import util
from openid.errors import ProtocolError
from openid.server import OpenIDServer
from openid.interface import Request, response_page, redirect
from openid.association import ServerAssociation

addr = 'http://localhost:8082/'

class ConcreteServer(OpenIDServer):
    def __init__(self):
        OpenIDServer.__init__(self, random.SystemRandom())
        self.counter = 0
        self.assoc_store = {}
        self.trust_store = set()  # (identity, trust_root)

        self.secret_handle = None
        self.lifespan = 60 * 60 * 24 * 30 # 30 days

    def handle(self, req):
        # This is reimplemented in the subclass so that extra
        # debugging/tracing information can be extracted.  It isn't
        # necessary in the general case.
        print 'handling openid.mode=%r' % (req.get('mode'),)
        return OpenIDServer.handle(self, req)

    def get_new_secret(self, assoc_type):
        tmpl = '{%s}%i/%i'
        if assoc_type == 'HMAC-SHA1':
            self.counter += 1

            secret = random_string(20, self.srand)
            assoc_handle = tmpl % (assoc_type, time.time(), self.counter)
            replace_after_offset = 60 * 60
            expiry_offset = replace_after_offset + 60 * 60

            assoc = ServerAssociation(
                assoc_handle, secret, expiry_offset, replace_after_offset)

{'fraction_non_alphanumeric': 0.08858713223407695, 'fraction_numerical': 0.018105399288716458, 'mean_word_length': 2.886934673366834, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4086642', 'n_tokens_mistral': 961, 'n_tokens_neox': 879, 'n_words': 253}