source: TI12-security/trunk/python/Tests/SimpleCA/SimpleCAServer.py @ 1665

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/SimpleCA/SimpleCAServer.py@1665
Revision 1665, 2.3 KB checked in by pjkersha, 13 years ago (diff)

Commented out WS-Security handlers for tests.

  • Property svn:executable set to *
RevLine 
[1532]1#!/bin/env python
2#
3# How to build an echo server using the extended code generation
4#
5
6import sys
7
8# Import the ZSI stuff you'd need no matter what
9from ZSI.ServiceContainer import ServiceContainer
10
11# This is a new method imported to show it's value
12from ZSI.ServiceContainer import GetSOAPContext
13
14# Import the generated Server Object
15import SimpleCA_interface
16
17import wsSecurity
18
19# Create a Server implementation
20
21# This using a derived server instead
22class SimpleCAServIn(SimpleCA_interface.SimpleCAService):
23    def __init__(self, post='', **kw):
24       
25        SimpleCA_interface.SimpleCAService.__init__(self, post, **kw)
26       
27        # Fudge to copy methods of this class so that equivalent
28        # SimpleCAService class WS stub picks it up
29        self.impl = self
30
[1665]31#        self.signatureHandler = wsSecurity.SignatureHandler(\
32#                                    certFilePath='../Junk-cert.pem',
33#                                    priKeyFilePath='../Junk-key.pem',
34#                                    priKeyPwd=open('../tmp2').read().strip())
35#       
36#       
37#    def sign(self, sw):
38#        '''\
39#        Overrides ServiceInterface class method to allow digital signature'''
40#        self.signatureHandler.sign(sw)
41#
42#       
43#    def verify(self, ps):
44#        '''\
45#        Overrides ServiceInterface class method to allow signature
46#        verification'''
47#        self.signatureHandler.verify(ps)
[1532]48       
[1665]49    def encrypt(self, sw):
50        pass
51   
52    def decrypt(self, ps):
53        pass
[1532]54       
55    def authorize(self, auth_info, post, action):
56        print "Authorizing INHERIT SimpleCA"
57        ctx = GetSOAPContext()
58        print dir(ctx)
59        print "Container: ", ctx.connection
60        print "Parsed SOAP: ", ctx.parsedsoap
61        print "Container: ", ctx.container
62        print "HTTP Headers:\n", ctx.httpheaders
63        print "----"
64        print "XML Data:\n", ctx.xmldata
65        return 1
66
67    def reqCert(self, input):
[1665]68        #import pdb;pdb.set_trace()
[1532]69        return 'SIGNED CERTIFICATE', 'OK'
70
71
72# Here we set up the server
73serviceContainer = ServiceContainer(('localhost', 5001))
74
75# Create the Inherited version of the server
76simpleCAsrv = SimpleCAServIn()
77serviceContainer.setNode(simpleCAsrv, url="/SimpleCAServIn")
78
79# Run the service container
80try:
81    serviceContainer.serve_forever()
82except KeyboardInterrupt:
83    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.