source: TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/authz/xacml/match.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/match.py@6643
Revision 6643, 1.9 KB checked in by pjkersha, 11 years ago (diff)

Contd port of MSI Policy + PDP implementation to XACML 2.0

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