source: TI12-security/trunk/NDG_XACML/ndg/xacml/core/rule.py @ 6745

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

Moved modules into core package

Line 
1"""NDG Security Rule type definition
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "25/02/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: $"
12from ndg.security.common.utils import TypedList
13from ndg.xacml import PolicyComponent
14from ndg.xacml.target import Target
15from ndg.xacml.condition import Condition
16
17
18class Rule(PolicyComponent):
19    """XACML Policy Rule"""
20    ELEMENT_LOCAL_NAME = 'Rule'
21   
22    __slots__ = (
23        '__targets', 
24        '__conditions', 
25        '__description', 
26        '__id', 
27        '__effect'
28    )
29   
30    def __init__(self):
31        self.__id = None
32        self.__effect = None
33        self.__targets = TypedList(Target)
34        self.__conditions = TypedList(Condition)
35       
36    @property
37    def targets(self):
38        "list of Rule targets"
39        return self.__targets
40   
41    @property
42    def conditions(self):
43        "list of rule conditions"
44        return self.__conditions
45       
46    def _get_id(self):
47        return self.__id
48
49    def _set_id(self, value):
50        if not isinstance(value, basestring):
51            raise TypeError('Expecting %r type for "id" '
52                            'attribute; got %r' % (basestring, type(value)))
53           
54        self.__id = value   
55
56    id = property(_get_id, _set_id, None, "Rule identifier attribute") 
57     
58    def _get_effect(self):
59        return self.__effect
60
61    def _set_effect(self, value):
62        if not isinstance(value, basestring):
63            raise TypeError('Expecting %r type for "effect" '
64                            'attribute; got %r' % (basestring, type(value)))
65           
66        self.__effect = value   
67
68    effect = property(_get_effect, _set_effect, None, 
69                      "Rule effect attribute") 
70
71    def _getDescription(self):
72        return self.__description
73
74    def _setDescription(self, value):
75        if not isinstance(value, basestring):
76            raise TypeError('Expecting string type for "description" '
77                            'attribute; got %r' % type(value))
78        self.__description = value
79
80    description = property(_getDescription, _setDescription, 
81                           doc="Rule Description text")
Note: See TracBrowser for help on using the repository browser.