1 | """NDG Security Match 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.xacml import PolicyComponent |
---|
13 | from ndg.xacml.attribute import AttributeValue |
---|
14 | |
---|
15 | |
---|
16 | class 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 | |
---|
61 | class SubjectMatch(MatchBase): |
---|
62 | "Subject Match Type" |
---|
63 | ELEMENT_LOCAL_NAME = 'SubjectMatch' |
---|
64 | |
---|
65 | |
---|
66 | class ResourceMatch(MatchBase): |
---|
67 | "Resource Match" |
---|
68 | ELEMENT_LOCAL_NAME = 'ResourceMatch' |
---|
69 | |
---|
70 | |
---|
71 | class ActionMatch(MatchBase): |
---|
72 | "Action match" |
---|
73 | ELEMENT_LOCAL_NAME = 'ActionMatch' |
---|
74 | |
---|
75 | |
---|
76 | class EnvironmentMatch(MatchBase): |
---|
77 | "Environment Match" |
---|
78 | ELEMENT_LOCAL_NAME = 'EnvironmentMatch' |
---|
79 | |
---|