docbow: add a new timestamping provider

This commit is contained in:
Benjamin Dauvergne 2013-10-17 23:02:24 +02:00
parent 658e6bad31
commit 4ebbcb794e
4 changed files with 19 additions and 4 deletions

View File

@ -14,3 +14,4 @@ DOCBOW_MENU = getattr(settings, 'DOCBOW_MENU', [
('contact', ugettext_noop('contact_menu')),
])
BASE_URL = getattr(settings, 'DOCBOW_BASE_URL', 'http://localhost:8000')
TIMESTAMP_PROVIDER = getattr(settings, 'DOCBOW_TIMESTAMP_PROVIDER', 'certum')

Binary file not shown.

View File

@ -3,17 +3,30 @@ import os.path
from django.utils import simplejson
__certificate_path = os.path.join(os.path.dirname(__file__), 'certum_certificate.crt')
from . import app_settings
__timestamper = rfc3161.RemoteTimestamper('http://time.certum.pl',
certificate=open(__certificate_path).read())
PROVIDERS = {
'certum': {
'url': 'http://time.certum.pl',
'certificate': file(os.path.join(os.path.dirname(__file__), 'certum_certificate.crt')).read(),
},
'e_szigno': {
'url': 'https://teszt.e-szigno.hu:440/tsa',
'certificate': file(os.path.join(os.path.dirname(__file__), 'e_szigno_test_tsa2.crt')).read(),
'username': 'teszt',
'password': 'teszt',
'hashname': 'sha256',
},
}
class TimestampingError(RuntimeError):
pass
def timestamp(content):
kwargs = PROVIDERS[app_settings.TIMESTAMP_PROVIDER]
timestamper = rfc3161.RemoteTimestamper(**kwargs)
try:
return __timestamper(data=content)
return timestamper(data=content)
except Exception, e:
raise TimestampingError(e)

View File

@ -76,6 +76,7 @@ __ENVIRONMENT_DEFAULTS = dict(
TEMPLATE_CONTEXT_PROCESSORS=django.conf.global_settings.TEMPLATE_CONTEXT_PROCESSORS+('django.core.context_processors.request',),
DATE_INPUT_FORMATS=('%d/%m/%Y', '%Y-%m-%d'),
CRISPY_TEMPLATE_PACK='uni_form',
DOCBOW_TIMESTAMP_PROVIDER='certum',
)
for key, default in __ENVIRONMENT_DEFAULTS.iteritems():