1 | #!/usr/bin/env python |
---|
2 | # |
---|
3 | # How to build an AttributeAuthority server using the extended code generation |
---|
4 | # |
---|
5 | import sys |
---|
6 | |
---|
7 | # Import the ZSI stuff you'd need no matter what |
---|
8 | from ZSI.ServiceContainer import ServiceContainer, SOAPRequestHandler |
---|
9 | |
---|
10 | # This is a new method imported to show it's value |
---|
11 | from ZSI.ServiceContainer import GetSOAPContext |
---|
12 | |
---|
13 | # Import the generated Server Object |
---|
14 | from ndg.security.common.zsi.attributeauthority.AttAuthority_services_server import AttAuthorityService |
---|
15 | |
---|
16 | |
---|
17 | # Create a Server implementation |
---|
18 | |
---|
19 | #_____________________________________________________________________________ |
---|
20 | class 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(AttAuthorityService._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 = "/AttAuthorityServIn" |
---|
36 | SOAPRequestHandler.do_POST(self) |
---|
37 | |
---|
38 | class AttributeAuthorityImpl(AttAuthorityService): |
---|
39 | |
---|
40 | def soap_getAttCert(self, ps, **kw): |
---|
41 | #import pdb;pdb.set_trace() |
---|
42 | response = AttAuthorityService.soap_getAttCert(self, ps) |
---|
43 | response.set_element_attCert('ATTRIBUTE CERT') |
---|
44 | return response |
---|
45 | |
---|
46 | # Here we set up the server |
---|
47 | serviceContainer = ServiceContainer(('localhost', 5700), |
---|
48 | RequestHandlerClass=AttributeAuthoritySOAPRequestHandler) |
---|
49 | |
---|
50 | |
---|
51 | # Create the Inherited version of the server |
---|
52 | import sys |
---|
53 | service = AttributeAuthorityImpl() |
---|
54 | serviceContainer.setNode(service, url="/AttAuthorityServIn") |
---|
55 | |
---|
56 | try: |
---|
57 | # Run the service container |
---|
58 | serviceContainer.serve_forever() |
---|
59 | except KeyboardInterrupt: |
---|
60 | sys.exit(0) |
---|