source: TI12-security/trunk/python/ndg.security.server/ndg/security/server/zsi/twisted/__init__.py @ 4404

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.server/ndg/security/server/zsi/twisted/__init__.py@4404
Revision 4404, 2.3 KB checked in by pjkersha, 12 years ago (diff)

Updated contact e-mail address

Line 
1"""Package for ZSI Web service bindings compliants to Twisted application
2server interface
3
4These may be deprecated in the future in favour of a WSGI interface
5
6NERC Data Grid Project"""
7__author__ = "P J Kershaw"
8__date__ = "27/10/08"
9__copyright__ = "(C) 2008 STFC & NERC"
10__license__ = \
11"""This software may be distributed under the terms of the Q Public
12License, version 1.0 or later."""
13__contact__ = "Philip.Kershaw@stfc.ac.uk"
14__revision__ = '$Id$'
15
16"""WS-Security digital signature handler for Twisted framework
17
18(moved from ndg.security.common.wsSecurity)
19
20This is used by NDG-Security server side code ONLY
21
22NERC Data Grid Project
23"""
24__author__ = "P J Kershaw"
25__date__ = "28/08/07"
26__copyright__ = "(C) 2007 STFC & NERC"
27__license__ = \
28"""This software may be distributed under the terms of the Q Public
29License, version 1.0 or later."""
30__contact__ = "Philip.Kershaw@stfc.ac.uk"
31__revision__ = '$Id: twisted.py 2909 2007-09-28 14:22:21Z pjkersha $'
32
33from zope.interface import classProvides, implements, Interface
34from ZSI.twisted.WSresource import DefaultHandlerChain, \
35    DefaultCallbackHandler, HandlerChainInterface, DataHandler
36
37   
38class WSSecurityHandlerChainFactory:
39    protocol = DefaultHandlerChain
40   
41    @classmethod
42    def newInstance(cls):
43        return cls.protocol(DefaultCallbackHandler, 
44                            DataHandler,
45                            WSSecurityHandler)
46
47class WSSecurityHandler:
48    classProvides(HandlerChainInterface)
49
50    signatureHandler = None
51   
52    @classmethod
53    def processRequest(cls, ps, **kw):
54        """Callback for verifying a signature.
55       
56        @param ps: instance representing SOAP request Body.
57        @type ps: ZSI.parse.ParsedSoap
58        @return ps: instance representing SOAP request Body
59        @rtype ps: ZSI.parse.ParsedSoap
60        """
61        if cls.signatureHandler:
62            cls.signatureHandler.verify(ps)
63           
64        return ps
65   
66    @classmethod
67    def processResponse(cls, sw, **kw):
68        """Callback for signing an outbound message.
69       
70        @param ps: instance representing SOAP response Body.
71        @type ps: ZSI.writer.SoapWriter
72        @return ps: instance representing SOAP response Body
73        @rtype ps: ZSI.writer.SoapWriter
74        """
75        if cls.signatureHandler:
76            cls.signatureHandler.sign(sw)
77           
78        return sw
Note: See TracBrowser for help on using the repository browser.