1 """NDG XACML exception types for the context package
2
3 NERC 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: exceptions.py 7087 2010-06-25 11:23:09Z pjkersha $"
12 from ndg.xacml.core.context.response import Response
13 from ndg.xacml.core.context.result import Result, Decision, StatusCode
14
15
16 -class 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
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
56 -class XacmlContextTypeError(XacmlContextError):
57 """Type errors within XACML context processing"""
58
61 """AttributeDesignator or AttributeSelector has specified MustBePresent
62 but the request context contains no match for required attribute XPath
63 respectively
64 """
65