source: TI12-security/trunk/ndg_xacml/ndg/xacml/core/context/exceptions.py @ 7087

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/ndg_xacml/ndg/xacml/core/context/exceptions.py@7087
Revision 7087, 2.2 KB checked in by pjkersha, 10 years ago (diff)

Incomplete - task 2: XACML-Security Integration

  • updating epydoc ready for release.
  • Property svn:keywords set to Id
Line 
1"""NDG XACML exception types for the context package
2
3NERC DataGrid
4"""
5__author__ = "P J Kershaw"
6__date__ = "01/04/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$"
12from ndg.xacml.core.context.response import Response
13from ndg.xacml.core.context.result import Result, Decision, StatusCode
14
15
16class XacmlContextError(Exception):   
17    """Base class for exceptions related XACML context handling
18   
19    @ivar __response: Context response object associated with this exception
20    @type __response: ndg.xacml.core.context.response.Response
21    """
22   
23    def __init__(self, *arg, **kw):
24        """Override Exception base class so as to add the response object in
25        the exception instance
26       
27        @param arg: base class arguments
28        @type arg: tuple
29        @param kw: base class keywords if any
30        @type kw: dict
31        """
32        super(XacmlContextError, self).__init__(*arg, **kw)
33        self.__response = Response()
34        self.__response.results.append(Result.createInitialised())
35       
36        self.__response.results[0].decision = Decision.INDETERMINATE
37        if len(arg) > 0:
38            self.__response.results[0].status.statusMessage = arg[0]
39       
40    @property
41    def response(self):
42        """
43        @return: Context response object associated with this exception
44        @rtype: ndg.xacml.core.context.response.Response
45        """
46        return self.__response
47   
48    @response.setter
49    def response(self, value):
50        if not isinstance(value, Response):
51            raise TypeError('Expecting %r type for "response" attribute; got '
52                            '%r instead' % (Response, type(Response)))
53        self.__response = value
54
55
56class XacmlContextTypeError(XacmlContextError):
57    """Type errors within XACML context processing"""
58           
59       
60class MissingAttributeError(XacmlContextError):
61    """AttributeDesignator or AttributeSelector has specified MustBePresent
62    but the request context contains no match for required attribute XPath
63    respectively
64    """
Note: See TracBrowser for help on using the repository browser.