source: TI12-security/trunk/python/ndg_security_server/ndg/security/server/wsgi/openid/provider/axinterface/__init__.py @ 5929

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg_security_server/ndg/security/server/wsgi/openid/provider/axinterface/__init__.py@5929
Revision 5929, 2.9 KB checked in by pjkersha, 10 years ago (diff)

Working unit tests for MyProxy? SAML Attribute assertion callout. TODO: add console script entry point.

Line 
1"""WSGI Middleware components - OpenID Provider package Attribute Exchange
2Interface plugins sub-package
3
4NERC DataGrid Project"""
5__author__ = "P J Kershaw"
6__date__ = "27/03/09"
7__copyright__ = "(C) 2009 Science and Technology Facilities Council"
8__license__ = "BSD - see LICENSE file in top-level directory"
9__contact__ = "Philip.Kershaw@stfc.ac.uk"
10__revision__ = '$Id$'
11from ndg.security.server.wsgi.openid.provider import IdentityMapping
12
13class AXInterfaceError(Exception):
14    """Base class for Attribute Exchange Interface Errors"""
15
16class AXInterfaceConfigError(AXInterfaceError):
17    """Attribute Exchange Interface configuration error"""
18
19class MissingRequiredAttrs(AXInterfaceError):
20    """Raised by the AXInterface __call__ method if the Relying Party has
21    requested attributes that this OpenID Provider cannot or is unable to
22    release"""
23
24class AXInterfaceReloginRequired(AXInterfaceError):
25    """Raise from AXInterface.__call__ if re-login is required"""
26   
27class AXInterface(object):
28    """Interface class for OpenID Provider to respond to Attribute Exchange
29    Requests from a Relying Party"""
30    __slots__ = ()
31   
32    userIdentifier2IdentityURI = IdentityMapping.userIdentifier2IdentityURI
33    identityUri2UserIdentifier = IdentityMapping.identityUri2UserIdentifier
34     
35    def __init__(self, **cfg):
36        """Add custom settings from the OpenID Provider's
37        openid.provider.axResponseHandler.* settings contained in the host
38        Paste ini file
39       
40        @type cfg: dict
41        @param cfg: dictionary of configuration parameters read in from
42        openid.provider.axinterface.* config settings.
43        @raise AXInterfaceConfigError: if settings are missing or incorrect"""
44        raise NotImplementedError()
45   
46    def __call__(self, ax_req, ax_resp, authnInterface, authnCtx):
47        """Add the attributes to the ax_resp object requested in the ax_req
48        object.  If it is not possible to return them, raise
49        MissingRequiredAttrs error
50       
51        @type ax_req: openid.extensions.ax.FetchRequest
52        @param ax_req: attribute exchange request object.  To find out what
53        attributes the Relying Party has requested for example, call
54        ax_req.getRequiredAttrs()
55        @type ax_resp: openid.extensions.ax.FetchResponse
56        @param ax_resp: attribute exchange response object.  This method should
57        update the settings in this object.  Use addValue and setValues methods
58        @type authnInterface: AbstractAuthNInterface
59        @param authnInterface: custom authentication interface set
60        at login.  See
61        ndg.security.server.openid.provider.AbstractAuthNInterface for more
62        information
63        @type authnCtx: dict like
64        @param authnCtx: session containing authentication context information
65        such as username and OpenID user identifier URI snippet
66        """
67        raise NotImplementedError()
Note: See TracBrowser for help on using the repository browser.