source: TI12-security/trunk/python/Tests/AttAuthority/AttAuthorityServer.py @ 4392

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

Rerun Credential Wallet and AA client unittests with refactored WSDL stubs in place.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2#
3# How to build an AttributeAuthority server using the extended code generation
4#
5import sys
6
7# Import the ZSI stuff you'd need no matter what
8from ZSI.ServiceContainer import ServiceContainer, SOAPRequestHandler
9
10# This is a new method imported to show it's value
11from ZSI.ServiceContainer import GetSOAPContext
12
13# Import the generated Server Object
14from ndg.security.common.zsi.attributeauthority.AttributeAuthority_services_server import AttributeAuthorityService
15
16   
17# Create a Server implementation
18
19#_____________________________________________________________________________
20class AttributeAuthoritySOAPRequestHandler(SOAPRequestHandler):
21     """Add a do_GET method to return the WSDL on HTTP GET requests.
22     Please note that the path to the wsdl file is derived from what
23     the HTTP invocation delivers (which is put into the self.path
24     attribute), so you might want to change this addressing scheme.
25     """
26     def do_GET(self):
27         """Return the WSDL file."""         
28         self.send_xml(AttributeAuthorityService._wsdl)
29         
30     def do_POST(self):
31          """Fudge to get _Dispatch to pick up the correct address
32          - seems to be necessary when putting proxy redirect for port in
33          the wsdl e.g. http://glue.badc.rl.ac.uk/sessionMgr points to the
34          default port for the Session Manager."""
35          self.path = "/AttributeAuthorityServIn"
36          SOAPRequestHandler.do_POST(self)
37   
38class AttributeAuthorityImpl(AttributeAuthorityService):
39
40     def soap_getAttCert(self, ps, **kw):
41         #import pdb;pdb.set_trace()
42         response = AttributeAuthorityService.soap_getAttCert(self, ps)
43         response.set_element_attCert('ATTRIBUTE CERT')
44         return response
45     
46# Here we set up the server
47serviceContainer = ServiceContainer(('localhost', 5700),
48                RequestHandlerClass=AttributeAuthoritySOAPRequestHandler)
49
50
51# Create the Inherited version of the server
52import sys
53service = AttributeAuthorityImpl()
54serviceContainer.setNode(service, url="/AttributeAuthorityServIn")
55
56try:
57    # Run the service container
58    serviceContainer.serve_forever()
59except KeyboardInterrupt:
60    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.