1 """NDG Security SOAP Service Middleware
2
3 NERC DataGrid Project
4
5 """
6 __author__ = "P J Kershaw"
7 __date__ = "27/05/08"
8 __copyright__ = "(C) 2009 Science and Technology Facilities Council"
9 __contact__ = "Philip.Kershaw@stfc.ac.uk"
10 __license__ = "BSD - see LICENSE file in top-level directory"
11 __revision__ = "$Id: $"
12 import logging
13 log = logging.getLogger(__name__)
17 """Base error handling exception class for the SOAP WSGI middleware module
18 """
19 _log = log
21 '''Extend to enable logging of errors'''
22 if len(arg) > 0:
23 self.__class__._log.error(arg[0])
24 Exception.__init__(self, *arg, **kw)
25
28 """SOAP Middleware read error"""
29
32 """SOAP Middleware configuration error"""
33
36 """SOAP WSGI base class"""
37 SOAP_FAULT_SET_KEYNAME = 'ndg.security.server.wsgi.soap.soapFault'
38 SOAP_ACTION_ENVIRON_KEYNAME = 'HTTP_SOAPACTION'
39
40 _str2Bool = lambda str: str.lower() in ["yes", "true", "t", "1"]
41 str2Bool = staticmethod(_str2Bool)
42
43 @classmethod
45 '''Generic method to filter out non-soap messages
46
47 TODO: is HTTP_SOAPACTION only set for WSDL doc-literal wrapped style
48 generated content? - If so this test should be moved'''
49 return environ.get('REQUEST_METHOD', '') == 'POST' and \
50 environ.get(cls.SOAP_ACTION_ENVIRON_KEYNAME) is not None
51
52 @classmethod
54 '''Check environment for SOAP fault flag set. This variable is set
55 from exception2SOAPFault'''
56 return environ.get(cls.SOAP_FAULT_SET_KEYNAME, False) == True
57
58 @classmethod
60 """Set-up using a Paste app factory pattern.
61
62 @type app: callable following WSGI interface
63 @param app: next middleware application in the chain
64 @type global_conf: dict
65 @param global_conf: PasteDeploy global configuration dictionary
66 @type app_conf: dict
67 @param app_conf: PasteDeploy application specific configuration
68 dictionary
69 """
70 app = cls(app)
71 app.initialise(global_conf, **app_conf)
72
73 return app
74
76 """Set attributes from keyword dictionaries global and or app_conf
77 @type global_conf: dict
78 @param global_conf: PasteDeploy global configuration dictionary
79 @type prefix: basestring
80 @param prefix: prefix for configuration items
81 @type app_conf: dict
82 @param app_conf: PasteDeploy application specific configuration
83 """
84 raise NotImplementedError()
85