source: TI12-security/trunk/NDG_XACML/ndg/xacml/core/functions/v1/anyuri_equal.py @ 6790

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDG_XACML/ndg/xacml/core/functions/v1/anyuri_equal.py@6790
Revision 6790, 1.2 KB checked in by pjkersha, 10 years ago (diff)
  • Added marshalling function for condition <Apply> to marshall inputs for given functionId.
  • implemented string-at-least-one-member-of function.
Line 
1"""NDG XACML URI equal matching function module
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "26/03/10"
7__copyright__ = ""
8__license__ = "BSD - see LICENSE file in top-level directory"
9__contact__ = "Philip.Kershaw@stfc.ac.uk"
10__revision__ = '$Id: $'
11import re
12
13from ndg.xacml.core.functions import AbstractFunction
14
15
16class AnyURIEqual(AbstractFunction):
17    """Any URI equal matching function -
18   
19    urn:oasis:names:tc:xacml:1.0:function:anyURI-equal
20    """
21    FUNCTION_NS = 'urn:oasis:names:tc:xacml:1.0:function:anyURI-equal'
22   
23    def evaluate(self, uri1, uri2):
24        """Match input URIs
25       
26        @param uri1: first of two URIs to match
27        @type uri1: basestring
28        @param uri2: second URI
29        @type uri2: basestring
30        @return: True if URIs match, False otherwise
31        @rtype: bool
32        """
33        if not isinstance(uri1, basestring):
34            raise TypeError('Expecting %r derived type for "uri1"; got %r' %
35                            (basestring, type(uri1)))
36           
37        if not isinstance(uri2, basestring):
38            raise TypeError('Expecting %r derived type for "uri2"; got %r' %
39                            (basestring, type(uri2)))
40           
41        return uri1 == uri2
42
Note: See TracBrowser for help on using the repository browser.