1 """NDG XACML policy finder resolving within base policy document
2
3 NERC DataGrid
4 """
5 __author__ = "R B Wilkinson"
6 __date__ = "03/11/11"
7 __copyright__ = "(C) 2011 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
13 import os
14
15 from ndg.xacml.finder.urlpolicyfinder import UrlPolicyFinder
16
18 """
19 Constructs a default policy finder, using the location of root policy file
20 if this can be determined. This implementation always returns a
21 UrlPolicyFinder.
22 @param: source
23 @type: string, file, XML node type
24 @return: default policy finder
25 @rtype: subclass of ndg.xacml.finder.policyfinderbase.PolicyFinderBase
26 """
27
28
29 basePath = None
30 if isinstance(source, str):
31 if os.path.exists(source):
32 basePath = os.path.dirname(source)
33 elif isinstance(source, file):
34 if hasattr(file, 'name') and file.name:
35 basePath = os.path.dirname(file.name)
36 finder = UrlPolicyFinder(basePath)
37 return finder
38