source: TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/authz/xacml/rule.py @ 6643

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg-security/TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/authz/xacml/rule.py@6643
Revision 6643, 2.1 KB checked in by pjkersha, 11 years ago (diff)

Contd port of MSI Policy + PDP implementation to XACML 2.0

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