source: TI12-security/trunk/python/Tests/xacml/test_xacml.py @ 5093

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/xacml/test_xacml.py@5093
Revision 5093, 1.7 KB checked in by pjkersha, 11 years ago (diff)

More functionality added to xacml module.

Line 
1from ndg.security.common.authz.xacml import AttributeDesignator, TargetMatch, \
2    Target
3
4
5def createPolicyTarget():
6    # OpenID designator
7    subjectDesignatorType = "http://www.w3.org/2001/XMLSchema#anyURI"
8    subjectDesignatorId = "urn:oasis:names:tc:xacml:1.0:subject:subject-id"
9   
10    subjectDesignator = AttributeDesignator(AttributeDesignator.SUBJECT_TARGET,
11                                            subjectDesignatorType,
12                                            subjectDesignatorId)
13
14   
15    subjectFunction = None
16    subjectValue = None
17   
18    subjectMatch = TargetMatch(TargetMatch.SUBJECT,
19                               subjectFunction,
20                               subjectDesignator,
21                               subjectValue)
22   
23    resourceDesignatorType ="http://www.w3.org/2001/XMLSchema#anyURI"
24    resourceDesignatorId ="urn:oasis:names:tc:xacml:1.0:resource:resource-id"
25
26    resourceMatchId = "urn:oasis:names:tc:xacml:1.0:function:anyURI-equal"
27
28    resourceDesignator=AttributeDesignator(AttributeDesignator.RESOURCE_TARGET,
29                                           resourceDesignatorType,
30                                           resourceDesignatorId)
31
32    resourceValue = "http://localhost:7080/secured"
33
34    resourceFunction = factory.createFunction(resourceMatchId);
35
36    resourceMatch = TargetMatch(TargetMatch.RESOURCE,
37                                resourceFunction,
38                                resourceDesignator,
39                                resourceValue)
40
41    resource.add(resourceMatch);
42
43    subjects = [subject]
44    resources = [resource]
45
46    # No action type attributes have been specified in the target
47    return Target(subjects, resources)
48
49if __name__ == "__main__":
50    createPolicyTarget()
Note: See TracBrowser for help on using the repository browser.