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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDGSecurity/python/Tests/SimpleCA/SimpleCAServer.py
Revision 7080, 2.0 KB checked in by pjkersha, 10 years ago (diff)
  • Property svn:executable set to *
  • Property svn:keywords set to Id
Line 
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
17# Create a Server implementation
18
19# This using a derived server instead
20class SimpleCAServIn(SimpleCA_interface.SimpleCAService):
21    def __init__(self, post='', **kw):
22       
23        SimpleCA_interface.SimpleCAService.__init__(self, post, **kw)
24       
25        # Fudge to copy methods of this class so that equivalent
26        # SimpleCAService class WS stub picks it up
27        self.impl = self
28#       
29#       
30#    def sign(self, sw):
31#        '''\
32#        Overrides ServiceInterface class method to allow digital signature'''
33#        self.signatureHandler.sign(sw)
34#
35#       
36#    def verify(self, ps):
37#        '''\
38#        Overrides ServiceInterface class method to allow signature
39#        verification'''
40#        self.signatureHandler.verify(ps)
41       
42    def encrypt(self, sw):
43        pass
44   
45    def decrypt(self, ps):
46        pass
47       
48    def authorize(self, auth_info, post, action):
49        print "Authorizing INHERIT SimpleCA"
50        ctx = GetSOAPContext()
51        print dir(ctx)
52        print "Container: ", ctx.connection
53        print "Parsed SOAP: ", ctx.parsedsoap
54        print "Container: ", ctx.container
55        print "HTTP Headers:\n", ctx.httpheaders
56        print "----"
57        print "XML Data:\n", ctx.xmldata
58        return 1
59
60    def reqCert(self, input):
61        #import pdb;pdb.set_trace()
62        return 'SIGNED CERTIFICATE', 'OK'
63
64
65# Here we set up the server
66serviceContainer = ServiceContainer(('localhost', 5001))
67
68# Create the Inherited version of the server
69simpleCAsrv = SimpleCAServIn()
70serviceContainer.setNode(simpleCAsrv, url="/SimpleCAServIn")
71
72# Run the service container
73try:
74    serviceContainer.serve_forever()
75except KeyboardInterrupt:
76    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.