1 | """NDG Security Rule type definition |
---|
2 | |
---|
3 | NERC 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: $" |
---|
12 | from ndg.security.common.utils import TypedList |
---|
13 | from ndg.security.common.authz.xacml import PolicyComponent |
---|
14 | from ndg.security.common.authz.xacml.target import Target |
---|
15 | from ndg.security.common.authz.xacml.condition import Condition |
---|
16 | |
---|
17 | |
---|
18 | class 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") |
---|