source: TI12-security/trunk/python/ndg.security.common/ndg/security/common/authz/xacml/cond/eval.py @ 5397

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.common/ndg/security/common/authz/xacml/cond/eval.py@5397
Revision 5397, 4.1 KB checked in by pjkersha, 11 years ago (diff)

ndg.security.common.authz.msi: added additional logging for PDP and PIP.
ndg.security.common.authz.xacml: added SetFunction? and ConditionSetFunction? implementations to enable support got at-least-one-member of rules.

Line 
1"""XACML eval module contains Evaluatable class
2
3NERC DataGrid Project
4
5This code is adapted from the Sun Java XACML implementation ...
6
7Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
8
9Redistribution and use in source and binary forms, with or without
10modification, are permitted provided that the following conditions are met:
11
12  1. Redistribution of source code must retain the above copyright notice,
13     this list of conditions and the following disclaimer.
14
15  2. Redistribution in binary form must reproduce the above copyright
16     notice, this list of conditions and the following disclaimer in the
17     documentation and/or other materials provided with the distribution.
18
19Neither the name of Sun Microsystems, Inc. or the names of contributors may
20be used to endorse or promote products derived from this software without
21specific prior written permission.
22
23This software is provided "AS IS," without a warranty of any kind. ALL
24EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
25ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
26OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
27AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
28AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
30REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
31INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
32OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
33EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
34
35You acknowledge that this software is not designed or intended for use in
36the design, construction, operation or maintenance of any nuclear facility.
37"""
38__author__ = "P J Kershaw"
39__date__ = "10/06/09"
40__copyright__ = "(C) 2009 Science and Technology Facilities Council"
41__contact__ = "Philip.Kershaw@stfc.ac.uk"
42__license__ = "BSD - see LICENSE file in top-level directory"
43__contact__ = "Philip.Kershaw@stfc.ac.uk"
44__revision__ = "$Id$"
45import logging
46log = logging.getLogger(__name__)
47
48     
49class EvaluationResult(object):
50    def __init__(self, 
51                 attributeValue=None, 
52                 status=None, 
53                 indeterminate=False):
54        self.status = status
55        self.attributeValue = attributeValue
56        self.indeterminate = indeterminate
57       
58       
59class Evaluatable(object):
60    '''Generic interface that is implemented by all objects that can appear in
61    an ApplyType. This lets the evaluation code of Apply and
62    functions iterate through their members and evaluate them, working only
63    on the returned values or errors.'''
64   
65    def evaluate(self, context):
66        '''Evaluates the object using the given context, and either returns an
67        error or a resulting value.
68   
69        @param context the representation of the request
70        @return the result of evaluation'''
71        raise NotImplementedError()
72
73    def getType(self):
74        '''Get the type of this object.  This may be the data type of an
75        Attribute or the return type of an
76        AttributeDesignator, etc.
77   
78        @return the type of data represented by this object'''
79        raise NotImplementedError()
80
81    def evaluatesToBag(self):
82        '''Tells whether evaluation will return a bag or a single value.
83   
84        @return true if evaluation will return a bag, false otherwise'''
85        raise NotImplementedError()
86
87    def getChildren(self):
88        '''Returns all children, in order, of this element in the Condition
89        tree, or en empty set if this element has no children. In XACML 1.x,
90        only the ApplyType ever has children.
91   
92        @return a list of Evaluatables'''
93        raise NotImplementedError()
94
95    def encode(self, output, indenter=None):
96        '''Encodes this Evaluatable into its XML representation and
97        writes this encoding to the given OutputStream with
98        indentation.
99   
100        @param output a stream into which the XML-encoded data is written
101        @param indenter an object that creates indentation strings'''
102        raise NotImplementedError()
Note: See TracBrowser for help on using the repository browser.