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

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

Moved modules into core package

Line 
1"""NDG Security Match 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 import PolicyComponent
13from ndg.xacml.attribute import AttributeValue
14
15
16class MatchBase(PolicyComponent):
17    ELEMENT_LOCAL_NAME = None
18   
19    __slots__ = (
20        '__attributeValue', 
21        '__attributeDesignator', 
22        '__attributeSelector',
23        '__matchId'
24    )
25   
26    def __init__(self):
27        self.__attributeValue = None
28         
29        # Either/or in schema
30        self.__attributeDesignator = None
31        self.__attributeSelector = None
32       
33        self.__matchId = None
34
35    def _get_attributeValue(self):
36        return self.__attributeValue
37
38    def _set_attributeValue(self, value):
39        if not isinstance(value, AttributeValue):
40            raise TypeError('Expecting %r type for "attributeValue" '
41                            'attribute; got %r' % (AttributeValue, type(value)))
42           
43        self.__attributeValue = value
44
45    attributeValue = property(_get_attributeValue, _set_attributeValue, None, 
46                              "attribute value")
47
48    def _getMatchId(self):
49        return self.__matchId
50
51    def _setMatchId(self, value):
52        if not isinstance(value, basestring):
53            raise TypeError('Expecting string type for "matchId" '
54                            'attribute; got %r' % type(value))
55           
56        self.__matchId = value
57
58    matchId = property(_getMatchId, _setMatchId, None, "Match Id")
59   
60   
61class SubjectMatch(MatchBase):
62    "Subject Match Type"
63    ELEMENT_LOCAL_NAME = 'SubjectMatch'
64   
65   
66class ResourceMatch(MatchBase):
67    "Resource Match"
68    ELEMENT_LOCAL_NAME = 'ResourceMatch'
69   
70   
71class ActionMatch(MatchBase):
72    "Action match"
73    ELEMENT_LOCAL_NAME = 'ActionMatch'
74   
75   
76class EnvironmentMatch(MatchBase):
77    "Environment Match"
78    ELEMENT_LOCAL_NAME = 'EnvironmentMatch'
79   
Note: See TracBrowser for help on using the repository browser.