source: TI12-security/trunk/NDG_XACML/ndg/xacml/core/attributedesignator.py @ 6792

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

Made ndg.xacml.core.expression.Expression abstract: derived classes must implement the evaluate method used to evaluate a result in a rule condition.

Line 
1"""NDG XACML AttributeDesignator type
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "16/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: $"
12from ndg.xacml.core.expression import Expression
13
14
15class AttributeDesignator(Expression):
16    '''XACML Attribute Designator type
17    '''
18    ATTRIBUTE_ID_ATTRIB_NAME = 'AttributeId'
19    ISSUER_ATTRIB_NAME = 'Issuer'
20    MUST_BE_PRESENT_ATTRIB_NAME = 'MustBePresent'
21   
22    __slots__ = ('__attributeId', '__issuer', '__mustBePresent')
23   
24    def __init__(self):
25        super(AttributeDesignator, self).__init__()
26        self.__attributeId = None
27        self.__issuer = None
28        self.__mustBePresent = False
29
30    @property
31    def attributeId(self):
32        """Get Attribute Id"""
33        return self.__attributeId
34
35    @attributeId.setter
36    def attributeId(self, value):
37        """Set Attribute Id"""
38        if not isinstance(value, basestring):
39            raise TypeError('Expecting %r type for "attributeId" '
40                            'attribute; got %r' % (basestring, type(value)))
41           
42        self.__attributeId = value 
43       
44    @property
45    def issuer(self):
46        """Get Issuer"""
47        return self.__issuer
48
49    @issuer.setter
50    def issuer(self, value):
51        """Set Issuer"""
52        if not isinstance(value, basestring):
53            raise TypeError('Expecting %r type for "issuer" '
54                            'attribute; got %r' % (basestring, type(value)))
55           
56        self.__issuer = value   
57
58    @property
59    def mustBePresent(self):
60        """Get Must Be Present flag"""
61        return self.__mustBePresent
62
63    @mustBePresent.setter
64    def mustBePresent(self, value):
65        """Set Must Be Present flag"""
66        if not isinstance(value, bool):
67            raise TypeError('Expecting %r type for "mustBePresent" '
68                            'attribute; got %r' % (bool, type(value)))
69           
70        self.__mustBePresent = value       
71
72   
73    def evaluate(self, context):
74        """Evaluate the result of the expression in a condition
75       
76        TODO: implement this placeholder
77       
78        @param context: the request context
79        @type context: ndg.xacml.core.context.request.Request
80        @return: attribute value(s) resulting from execution of this expression
81        in a condition
82        @rtype: AttributeValue/NoneType 
83        """ 
84        return self.__value
85       
86       
87class SubjectAttributeDesignator(AttributeDesignator):
88    """XACML Subject Attribute Designator type"""
89    ELEMENT_LOCAL_NAME = 'SubjectAttributeDesignator'
90       
91       
92class ResourceAttributeDesignator(AttributeDesignator):
93    """XACML Resource Attribute Designator type"""
94    ELEMENT_LOCAL_NAME = 'ResourceAttributeDesignator'
95   
96       
97class ActionAttributeDesignator(AttributeDesignator):
98    """XACML Action Attribute Designator type"""
99    ELEMENT_LOCAL_NAME = 'ActionAttributeDesignator'
100   
101   
102class EnvironmentAttributeDesignator(AttributeDesignator):
103    """XACML Environment Attribute Designator type"""
104    ELEMENT_LOCAL_NAME = 'EnvironmentAttributeDesignator'
Note: See TracBrowser for help on using the repository browser.