source: TI12-security/trunk/python/ndg.security.common/ndg/security/common/Gatekeeper/gatekeeper_services_server.py @ 2909

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.common/ndg/security/common/Gatekeeper/gatekeeper_services_server.py@2909
Revision 2909, 4.3 KB checked in by pjkersha, 13 years ago (diff)

Updated for epydoc: added double underscore vars module info

  • Property svn:keywords set to Id
Line 
1"""NDG Gatekeeper Web service server side interface.  Generated and
2adapted from:
3
4wsdl2dispatch -f gatekeeper.wsdl
5
6NERC Data Grid Project
7
8P J Kershaw 19/05/06
9
10Copyright (C) 2006 STFC & NERC
11
12This software may be distributed under the terms of the Q Public License,
13version 1.0 or later.
14"""
15__revision__ = '$Id$'
16
17from gatekeeper_services import *
18from ZSI.ServiceContainer import ServiceSOAPBinding
19
20from NDG.Gatekeeper import *
21
22
23class gatekeeper(ServiceSOAPBinding):
24    soapAction = {
25        'urn:gatekeeper#executeAccess': 'soap_executeAccess',
26        'urn:gatekeeper#readAccess': 'soap_readAccess',
27        'urn:gatekeeper#writeAccess': 'soap_writeAccess',
28        }
29
30    def __init__(self, srv, debug=False, post='/gatekeeper.wsdl', **kw):
31        ServiceSOAPBinding.__init__(self, post)
32       
33        if not isinstance(srv, Gatekeeper):
34            raise GatekeeperError("Expecting NDG Gatekeeper type object")
35           
36        self.__srv = srv       
37        self.__debug = debug
38
39
40    def soap_executeAccess(self, ps):
41        """Make a request for execute access to resource using an
42        Attribute Certificate"""
43
44        if self.__debug:
45            import pdb
46            pdb.set_trace()       
47       
48        # input vals in request object
49        reqArgs = ps.Parse(executeAccessRequestWrapper)       
50
51        # assign return values to response object
52        response = executeAccessResponseWrapper()
53       
54        response._matchingRole = ''
55        response._errMsg = ''
56       
57        try:           
58            attCert = AttCertParse(reqArgs._attCert)
59           
60            # Access method returns a dictionary of boolean access flags
61            # keyed by role name.  Find the first where access is True
62            # and return the corresponding role
63            for role, bAccess in self.__srv.executeAccess(attCert).items():               
64                if bAccess: 
65                    response._matchingRole = role
66                    break
67               
68        except Exception, e:
69            response._errMsg = str(e)
70     
71        return response
72
73
74    def soap_readAccess(self, ps):
75        """Make a request for execute access to resource using an
76        Attribute Certificate"""
77
78        if self.__debug:
79            import pdb
80            pdb.set_trace()       
81       
82        # input vals in request object
83        reqArgs = ps.Parse(readAccessRequestWrapper)       
84
85        # assign return values to response object
86        response = readAccessResponseWrapper()
87       
88        response._matchingRole = ''
89        response._errMsg = ''
90       
91        try:           
92            attCert = AttCertParse(reqArgs._attCert)
93           
94            # Access method returns a dictionary of boolean access flags
95            # keyed by role name.  Find the first where access is True
96            # and return the corresponding role
97            for role, bAccess in self.__srv.readAccess(attCert).items():               
98                if bAccess: 
99                    response._matchingRole = role
100                    break
101               
102        except Exception, e:
103            response._errMsg = str(e)
104     
105        return response
106           
107           
108    def soap_writeAccess(self, ps):
109        """Make a request for write access to resource using an
110        Attribute Certificate"""
111
112        if self.__debug:
113            import pdb
114            pdb.set_trace()       
115       
116        # input vals in request object
117        reqArgs = ps.Parse(writeAccessRequestWrapper)       
118
119        # assign return values to response object
120        response = writeAccessResponseWrapper()
121       
122        response._matchingRole = ''
123        response._errMsg = ''
124       
125        try:           
126            attCert = AttCertParse(reqArgs._attCert)
127           
128            # Access method returns a dictionary of boolean access flags
129            # keyed by role name.  Find the first where access is True
130            # and return the corresponding role
131            for role, bAccess in self.__srv.writeAccess(attCert).items():               
132                if bAccess: 
133                    response._matchingRole = role
134                    break
135               
136        except Exception, e:
137            response._errMsg = str(e)
138         
139        return response
140       
Note: See TracBrowser for help on using the repository browser.