
    h                         S r SSKJrJrJrJrJrJrJr  SSK	J
r
Jr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJrJr  SS	KJrJr  \\
   r\\\\/ S
4   4   r " S S\
5      r " S S5      rg
)z=
The point of integration of application and authentication.
    )CallableDictIterableListTupleTypeUnion)	Interface
providedBy)error)ICredentialsChecker)ICredentials)defer)DeferredmaybeDeferred)failurereflectNc            
       R    \ rS rSrSrS\\\S   4   S\S\	S\\
\   \4   4S jrSrg	)
IRealm#   zO
The realm connects application-specific objects to the
authentication system.
avatarId mind
interfacesreturnc                     g)am  
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.
Nr   )r   r   r   s      Z/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/cred/portal.pyrequestAvatarIRealm.requestAvatar)   s        N)__name__
__module____qualname____firstlineno____doc__r	   bytesr   object_InterfaceItselfr   _requestResultr   __static_attributes__r   r    r   r   r   #   sI    
uRy()17FV	x'7	8r    r   c            	           \ rS rSr% Sr\\\   \4   \	S'    SS\
S\\   SS4S jjrS\\\      4S jrS	\S
\\   SS4S jrS\S\S\\   S\\   4S jrSrg)PortalA   a  
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.
checkersrealmr   Nc                 R    Xl         0 U l        U H  nU R                  U5        M     g)z!
Create a Portal to a L{IRealm}.
N)r/   r.   registerChecker)selfr/   r.   checkers       r   __init__Portal.__init__P   s(     
G  )  r    c                 H    [        U R                  R                  5       5      $ )zB
Return list of credentials interfaces that can be used to login.
)listr.   keys)r2   s    r   listCredentialsInterfaces Portal.listCredentialsInterfaces[   s     DMM&&())r    r3   credentialInterfacesc                 X    U(       d  UR                   nU H  nXR                  U'   M     g )N)r;   r.   )r2   r3   r;   credentialInterfaces       r   r1   Portal.registerCheckera   s+     $#*#?#? #718MM-. $8r    credentialsr   r   c                    U R                    Hd  nUR                  U5      (       d  M  [        U R                   U   R                  U5      R                  " U R
                  R                  U/UQ76 s  $    [        U5      n[        R                  " [        R                  " [        R                  " SSR                  [        [        R                   U5      5      -  5      5      5      $ )a  
@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.
zNo checker for %sz, )r.   r   r   requestAvatarIdaddCallbackr/   r   r   failr   Failurer   UnhandledCredentialsjoinmapr   qual)r2   r?   r   r   iifacs         r   loginPortal.logini   s    J A||K(($MM!$44k+"jj66K?IK K 
 +&zzOO**'$))Cd4K*LL
 	
r    )r.   r/   )r   )r!   r"   r#   r$   r%   r   r   r
   r   __annotations__r   r   r4   r   r9   r1   r   r'   r   r)   rK   r*   r   r    r   r,   r,   A   s    
 4	?$7788 HJ	*	*'/0C'D	*		**4Y+@ *9*9CG	?9	91
'1
/51
DHO1
	.	!1
r    r,   )r%   typingr   r   r   r   r   r   r	   zope.interfacer
   r   twisted.credr   twisted.cred.checkersr   twisted.cred.credentialsr   twisted.internetr   twisted.internet.deferr   r   twisted.pythonr   r   r(   r'   r)   r   r,   r   r    r   <module>rV      sl   
 F E E 0  5 1 " : + 	? 
 '"d(1CCDY <Y
 Y
r    