Current Path : /usr/lib/python2.7/dist-packages/twisted/cred/ |
Current File : //usr/lib/python2.7/dist-packages/twisted/cred/portal.pyc |
[XMc @ s d Z d d l m Z d d l m Z d d l m Z m Z d d l m Z d d l m Z m Z d e f d YZ d d d YZ d S( s= The point of integration of application and authentication. i( t defer( t maybeDeferred( t failuret reflect( t error( t providedByt Interfacet IRealmc B s e Z d Z d Z RS( s[ The realm connects application-specific objects to the authentication system. c G s d S( s Return avatar which provides one of the given interfaces. @param avatarId: a string that identifies an avatar, as returned by L{ICredentialsChecker.requestAvatarId<twisted.cred.checkers.ICredentialsChecker.requestAvatarId>} (via a Deferred). Alternatively, it may be C{twisted.cred.checkers.ANONYMOUS}. @param mind: usually None. See the description of mind in L{Portal.login}. @param interfaces: the interface(s) the returned avatar should implement, e.g. C{IMailAccount}. See the description of L{Portal.login}. @returns: a deferred which will fire a tuple of (interface, avatarAspect, logout), or the tuple itself. The interface will be one of the interfaces passed in the 'interfaces' argument. The 'avatarAspect' will implement that interface. The 'logout' object is a callable which will detach the mind from the avatar. N( ( t avatarIdt mindt interfaces( ( s7 /usr/lib/python2.7/dist-packages/twisted/cred/portal.pyt requestAvatar s ( t __name__t __module__t __doc__R ( ( ( s7 /usr/lib/python2.7/dist-packages/twisted/cred/portal.pyR s t Portalc B s5 e Z d Z d d Z d Z d Z d Z RS( s A mediator between clients and a realm. A portal is associated with one Realm and zero or more credentials checkers. When a login is attempted, the portal finds the appropriate credentials checker for the credentials given, invokes it, and if the credentials are valid, retrieves the appropriate avatar from the Realm. This class is not intended to be subclassed. Customization should be done in the realm object and in the credentials checker objects. c C s4 | | _ i | _ x | D] } | j | q Wd S( s1 Create a Portal to a L{IRealm}. N( t realmt checkerst registerChecker( t selfR R t checker( ( s7 /usr/lib/python2.7/dist-packages/twisted/cred/portal.pyt __init__9 s c C s | j j S( sR Return list of credentials interfaces that can be used to login. ( R t keys( R ( ( s7 /usr/lib/python2.7/dist-packages/twisted/cred/portal.pyt listCredentialsInterfacesB s c G s4 | s | j } n x | D] } | | j | <q Wd S( N( t credentialInterfacesR ( R R R t credentialInterface( ( s7 /usr/lib/python2.7/dist-packages/twisted/cred/portal.pyR H s c G s xL | j D]A } | j | r t | j | j | j | j j | | Sq Wt | } t j t j t j d d j t t j | S( s @param credentials: an implementor of L{twisted.cred.credentials.ICredentials} @param mind: an object which implements a client-side interface for your particular realm. In many cases, this may be None, so if the word 'mind' confuses you, just ignore it. @param interfaces: list of interfaces for the perspective that the mind wishes to attach to. Usually, this will be only one interface, for example IMailAccount. For highly dynamic protocols, however, this may be a list like (IMailAccount, IUserChooser, IServiceInfo). To expand: if we are speaking to the system over IMAP, any information that will be relayed to the user MUST be returned as an IMailAccount implementor; IMAP clients would not be able to understand anything else. Any information about unusual status would have to be relayed as a single mail message in an otherwise-empty mailbox. However, in a web-based mail system, or a PB-based client, the ``mind'' object inside the web server (implemented with a dynamic page-viewing mechanism such as a Twisted Web Resource) or on the user's client program may be intelligent enough to respond to several ``server''-side interfaces. @return: A deferred which will fire a tuple of (interface, avatarAspect, logout). The interface will be one of the interfaces passed in the 'interfaces' argument. The 'avatarAspect' will implement that interface. The 'logout' object is a callable which will detach the mind from the avatar. It must be called when the user has conceptually disconnected from the service. Although in some cases this will not be in connectionLost (such as in a web-based session), it will always be at the end of a user's interactive session. s No checker for %ss , ( R R R t requestAvatarIdt addCallbackR R R t failR t FailureR t UnhandledCredentialst joint mapR t qual( R t credentialsR R t it ifac( ( s7 /usr/lib/python2.7/dist-packages/twisted/cred/portal.pyt loginN s #( ( R R R R R R R% ( ( ( s7 /usr/lib/python2.7/dist-packages/twisted/cred/portal.pyR - s N( ( R t twisted.internetR t twisted.internet.deferR t twisted.pythonR R t twisted.credR t zope.interfaceR R R R ( ( ( s7 /usr/lib/python2.7/dist-packages/twisted/cred/portal.pyt <module> s