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

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

Added more !ETree readers for the different types.

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.xacml.utils import TypedList
13from ndg.xacml.core import PolicyComponent
14from ndg.xacml.core.target import Target
15from ndg.xacml.core.condition import Condition
16
17
18class Rule(PolicyComponent):
19    """XACML Policy Rule"""
20    ELEMENT_LOCAL_NAME = 'Rule'
21    RULE_ID_ATTRIB_NAME = 'RuleId'
22    EFFECT_ATTRIB_NAME = 'Effect'
23   
24    DESCRIPTION_LOCAL_NAME = 'Description'
25   
26    __slots__ = (
27        '__target', 
28        '__condition', 
29        '__description', 
30        '__id', 
31        '__effect'
32    )
33   
34    def __init__(self):
35        self.__id = None
36        self.__effect = None
37        self.__target = None
38        self.__condition = None
39       
40    @property
41    def target(self):
42        "Rule target"
43        return self.__target
44   
45    @target.setter
46    def target(self, value):
47        if not isinstance(value, Target):
48            raise TypeError('Expecting %r type for "id" '
49                            'attribute; got %r' % (Target, type(value))) 
50        self.__target = value
51           
52    @property
53    def condition(self):
54        "rule condition"
55        return self.__condition
56   
57    @condition.setter
58    def condition(self, value):
59        if not isinstance(value, Condition):
60            raise TypeError('Expecting %r type for "id" '
61                            'attribute; got %r' % (Condition, type(value))) 
62           
63        self.__condition = value
64             
65    def _get_id(self):
66        return self.__id
67
68    def _set_id(self, value):
69        if not isinstance(value, basestring):
70            raise TypeError('Expecting %r type for "id" '
71                            'attribute; got %r' % (basestring, type(value)))
72           
73        self.__id = value   
74
75    id = property(_get_id, _set_id, None, "Rule identifier attribute") 
76     
77    def _get_effect(self):
78        return self.__effect
79
80    def _set_effect(self, value):
81        if not isinstance(value, basestring):
82            raise TypeError('Expecting %r type for "effect" '
83                            'attribute; got %r' % (basestring, type(value)))
84           
85        self.__effect = value   
86
87    effect = property(_get_effect, _set_effect, None, 
88                      "Rule effect attribute") 
89
90    def _getDescription(self):
91        return self.__description
92
93    def _setDescription(self, value):
94        if not isinstance(value, basestring):
95            raise TypeError('Expecting string type for "description" '
96                            'attribute; got %r' % type(value))
97        self.__description = value
98
99    description = property(_getDescription, _setDescription, 
100                           doc="Rule Description text")
Note: See TracBrowser for help on using the repository browser.