source: TI12-security/trunk/NDG_XACML/ndg/xacml/core/context/request.py @ 7064

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDG_XACML/ndg/xacml/core/context/request.py@7064
Revision 7064, 3.4 KB checked in by pjkersha, 10 years ago (diff)

Incomplete - task 2: XACML-Security Integration

  • added and and function and placeholders fro xpath-node-* functions
  • Property svn:keywords set to Id
Line 
1"""NDG XACML module for Request type
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "23/03/10"
7__copyright__ = "(C) 2010 Science and Technology Facilities Council"
8__contact__ = "Philip.Kershaw@stfc.ac.uk"
9__license__ = "BSD - see LICENSE file in top-level directory"
10__contact__ = "Philip.Kershaw@stfc.ac.uk"
11__revision__ = "$Id$"
12import logging
13log = logging.getLogger(__name__)
14
15from ndg.xacml.utils import TypedList
16from ndg.xacml.core.context import XacmlContextBase
17from ndg.xacml.core.context.subject import Subject
18from ndg.xacml.core.context.resource import Resource
19from ndg.xacml.core.context.action import Action
20from ndg.xacml.core.context.environment import Environment
21
22
23class Request(XacmlContextBase):
24    """XACML Request class
25   
26    @param ctxHandler: reference to context handler to enable the PDP to
27    query for additional attributes.  The Context Handler itself queries a
28    Policy Information Point.  This handler setting may be omitted.  If so,
29    the PDP will rely entirely on the input request context for making
30    access control decisions
31    @type ctxHandler: ndg.xacml.core.context.handler.CtxHandlerInterface /
32    None
33    """
34    __slots__ = (
35        '__subjects', 
36        '__resources', 
37        '__action', 
38        '__environment',
39        '__ctxHandler',
40    )
41    ELEMENT_LOCAL_NAME = 'Request'
42   
43    def __init__(self):
44        super(Request, self).__init__()
45       
46        self.__subjects = TypedList(Subject)
47        self.__resources = TypedList(Resource)
48        self.__action = None
49        self.__environment = None
50       
51        self.__ctxHandler = None
52                   
53    @property
54    def subjects(self):
55        """Request subjects"""
56        return self.__subjects
57       
58    @property
59    def resources(self):
60        """Request resources"""
61        return self.__resources
62                                   
63    @property
64    def action(self):
65        """Request action"""
66        return self.__action
67   
68    @action.setter
69    def action(self, value):
70        """Request action"""
71        if not isinstance(value, Action):
72            raise TypeError('Expecting %r type for request "action" '
73                            'attribute; got %r' % (Action, type(value)))
74           
75        self.__action = value
76                                   
77    @property
78    def environment(self):
79        """Request environment"""
80        return self.__environment
81   
82    @environment.setter
83    def environment(self, value):
84        """Request environment"""
85        if not isinstance(value, Environment):
86            raise TypeError('Expecting %r type for request "environment" '
87                            'attribute; got %r' % (Environment, type(value)))
88             
89        self.__environment = value   
90
91    @property
92    def ctxHandler(self):
93        """Get Context handler used by evaluate method to query the PIP for
94        additional attribute values
95        """
96        return self.__ctxHandler
97
98    @ctxHandler.setter
99    def ctxHandler(self, value):
100        """Set Context handler used by evaluate method to query the PIP for
101        additional attribute values
102        """
103        if not isinstance(value, CtxHandlerInterface):
104            raise TypeError('Expecting %r type for "ctxHandler" attribute; got '
105                            '%r' % (CtxHandlerInterface, type(value)))
106           
107        self.__ctxHandler = value
Note: See TracBrowser for help on using the repository browser.