source: TI12-security/trunk/python/Tests/dewsGatekeeper/gatekeeperServer.py @ 1957

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

Example code for Geoserver Gatekeeper web service interface for DEWS.

  • Property svn:executable set to *
Line 
1#!/usr/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
15from Gatekeeper_services_server import GatekeeperService
16
17import wsSecurity
18
19# Create a Server implementation
20
21# This using a derived server instead
22class GatekeeperServIn(GatekeeperService):
23    def __init__(self, post='', **kw):
24       
25        GatekeeperService.__init__(self, post, **kw)
26       
27#        self.signatureHandler = wsSecurity.SignatureHandler(\
28#                                    certFilePath='../Junk-cert.pem',
29#                                    priKeyFilePath='../Junk-key.pem',
30#                                    priKeyPwd=open('../tmp2').read().strip())
31#       
32#       
33#    def sign(self, sw):
34#        '''\
35#        Overrides ServiceInterface class method to allow digital signature'''
36#        self.signatureHandler.sign(sw)
37#
38#       
39#    def verify(self, ps):
40#        '''\
41#        Overrides ServiceInterface class method to allow signature
42#        verification'''
43#        self.signatureHandler.verify(ps)
44       
45    def authorize(self, auth_info, post, action):
46        print "Authorizing INHERIT Gatekeeper"
47        ctx = GetSOAPContext()
48        print dir(ctx)
49        print "Container: ", ctx.connection
50        print "Parsed SOAP: ", ctx.parsedsoap
51        print "Container: ", ctx.container
52        print "HTTP Headers:\n", ctx.httpheaders
53        print "----"
54        print "XML Data:\n", ctx.xmldata
55        return 1
56
57    def soap_get(self, ps, **kw):
58        #import pdb;pdb.set_trace()
59        response = GatekeeperService.soap_get(self, ps)
60        response._geoServerResponse = 'Geoserver Response'
61        return response
62
63
64# Here we set up the server
65serviceContainer = ServiceContainer(('localhost', 5000))
66
67# Create the Inherited version of the server
68Gatekeepersrv = GatekeeperServIn()
69serviceContainer.setNode(Gatekeepersrv, url="/GatekeeperServIn")
70
71# Run the service container
72try:
73    serviceContainer.serve_forever()
74except KeyboardInterrupt:
75    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.