5 from config import KEY_FILE, TICKET_SERVER_PORT
9 class TicketServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
10 allow_reuse_address = True
13 class TicketRequestHandler(SocketServer.StreamRequestHandler):
15 data = self.rfile.read()
16 filename = tools.write_temp_file(lambda thefile:
17 thefile.write(TEMPLATE % data))
18 result = subprocess.Popen([XMLSEC1, '--sign',
19 '--privkey-pem', KEY_FILE, filename],
20 stdout=subprocess.PIPE).stdout
21 self.wfile.write(result.read())
27 tools.as_daemon_thread(TicketServer(('', TICKET_SERVER_PORT),
28 TicketRequestHandler).serve_forever)
31 XMLSEC1 = '/usr/bin/xmlsec1'
33 TEMPLATE = '''<?xml version="1.0" encoding="UTF-8"?>
34 <Envelope xmlns="urn:envelope">
36 <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
38 <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
39 <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
42 <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
44 <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
45 <DigestValue></DigestValue>