Mercurial > moin > 1.9
comparison MoinMoin/util/moinoid.py @ 6103:500f68d3e2fd
remove our own usage of python_compatibility module
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Tue, 06 Sep 2016 01:00:25 +0200 |
parents | 817d99d715fe |
children |
comparison
equal
deleted
inserted
replaced
6102:df21062e294d | 6103:500f68d3e2fd |
---|---|
2 MoinMoin - OpenID utils | 2 MoinMoin - OpenID utils |
3 | 3 |
4 @copyright: 2006, 2007 Johannes Berg <johannes@sipsolutions.net> | 4 @copyright: 2006, 2007 Johannes Berg <johannes@sipsolutions.net> |
5 @license: GNU GPL, see COPYING for details. | 5 @license: GNU GPL, see COPYING for details. |
6 """ | 6 """ |
7 | 7 import hashlib |
8 from random import randint | 8 from random import randint |
9 import time | 9 import time |
10 | 10 |
11 from openid import oidutil | 11 from openid import oidutil |
12 from openid.store.interface import OpenIDStore | 12 from openid.store.interface import OpenIDStore |
13 from openid.association import Association | 13 from openid.association import Association |
14 from openid.store import nonce | 14 from openid.store import nonce |
15 | 15 |
16 from MoinMoin import caching | 16 from MoinMoin import caching |
17 from MoinMoin.support.python_compatibility import hash_new | |
18 | 17 |
19 from MoinMoin import log | 18 from MoinMoin import log |
20 logging = log.getLogger(__name__) | 19 logging = log.getLogger(__name__) |
21 | 20 |
22 # redirect openid logging to moin log | 21 # redirect openid logging to moin log |
51 self.request = request | 50 self.request = request |
52 OpenIDStore.__init__(self) | 51 OpenIDStore.__init__(self) |
53 | 52 |
54 def key(self, url): | 53 def key(self, url): |
55 '''return cache key''' | 54 '''return cache key''' |
56 return hash_new('sha1', url).hexdigest() | 55 return hashlib.new('sha1', url).hexdigest() |
57 | 56 |
58 def storeAssociation(self, server_url, association): | 57 def storeAssociation(self, server_url, association): |
59 ce = caching.CacheEntry(self.request, 'openid', self.key(server_url), | 58 ce = caching.CacheEntry(self.request, 'openid', self.key(server_url), |
60 scope='wiki', use_pickle=True) | 59 scope='wiki', use_pickle=True) |
61 if ce.exists(): | 60 if ce.exists(): |
102 else: | 101 else: |
103 ce.remove() | 102 ce.remove() |
104 | 103 |
105 def useNonce(self, server_url, timestamp, salt): | 104 def useNonce(self, server_url, timestamp, salt): |
106 val = ''.join([str(server_url), str(timestamp), str(salt)]) | 105 val = ''.join([str(server_url), str(timestamp), str(salt)]) |
107 csum = hash_new('sha1', val).hexdigest() | 106 csum = hashlib.new('sha1', val).hexdigest() |
108 ce = caching.CacheEntry(self.request, 'openid-nonce', csum, | 107 ce = caching.CacheEntry(self.request, 'openid-nonce', csum, |
109 scope='farm', use_pickle=False) | 108 scope='farm', use_pickle=False) |
110 if ce.exists(): | 109 if ce.exists(): |
111 # nonce already used! | 110 # nonce already used! |
112 return False | 111 return False |