
    qh}@                         S r / SQrSSKJr  SSKrSSKrSrSrSrSr	S	r
\R                  " S
5      rSrSr " S S\5      r " S S\5      r\\l         " S S\5      r\\l        g)zAn implementation of the OpenID Provider Authentication Policy
Extension 1.0, Draft 5

@see: http://openid.net/developers/specs/

@since: 2.1.0
)RequestResponsens_uriAUTH_PHISHING_RESISTANTAUTH_MULTI_FACTORAUTH_MULTI_FACTOR_PHYSICALLEVELS_NISTLEVELS_JISA    )	ExtensionNz+http://specs.openid.net/extensions/pape/1.0zEhttp://schemas.openid.net/pape/policies/2007/06/multi-factor-physicalz<http://schemas.openid.net/pape/policies/2007/06/multi-factorzBhttp://schemas.openid.net/pape/policies/2007/06/phishing-resistantz4http://schemas.openid.net/pape/policies/2007/06/nonez$^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$zDhttp://csrc.nist.gov/publications/nistpubs/800-63/SP800-63V1_0_2.pdfz*http://www.jisa.or.jp/spec/auth_level.htmlc                   :    \ rS rSr\\S.rS rS	S jrS r	S r
Srg)
PAPEExtension)   )nistjisac                 B    U R                   R                  5       U l        g N)_default_auth_level_aliasescopyauth_level_aliasesselfs    O/var/www/html/env/lib/python3.13/site-packages/openid/extensions/draft/pape5.py__init__PAPEExtension.__init__/   s    "&"B"B"G"G"I    Nc                     Uc   U R                  U5      nO0U R                  R	                  U5      nUb  X1:w  a  [        SX#U5      eXR                  U'   g! [         a    U R                  5       n N+f = f)zAdd an auth level URI alias to this request.

@param auth_level_uri: The auth level URI to send in the
    request.

@param alias: The namespace alias to use for this auth level
    in this message. May be None if the alias is not
    important.
Nz-Attempting to redefine alias %r from %r to %r)	_getAliasKeyError_generateAliasr   getr   auth_level_urialiasexisting_uris       r   _addAuthLevelAlias PAPEExtension._addAuthLevelAlias2   s     =.~6  2266u=L'L,JN$ND D *8&  .++-.s   A A32A3c                 n    [        S5       H  nSU4-  nX R                  ;  d  M  Us  $    [        S5      e)z!Return an unused auth level aliasi  zcust%dz,Could not find an unused alias (tried 1000!))ranger   RuntimeError)r   ir#   s      r   r   PAPEExtension._generateAliasI   s;    tAu$E333 
 IJJr   c                 p    U R                   R                  5        H  u  p#X:X  d  M  Us  $    [        U5      e)z]Return the alias for the specified auth level URI.

@raises KeyError: if no alias is defined
)r   itemsr   r!   s       r   r   PAPEExtension._getAliasR   s9    
 &*%<%<%B%B%D!U- &E ~&&r   )r   r   )__name__
__module____qualname____firstlineno__r   r	   r   r   r%   r   r   __static_attributes__ r   r   r   r   )   s&    #
J8.K	'r   r   c                   |   ^  \ rS rSrSrSr   SU 4S jjrS rS rSS jr	S r
S	 r\" \5      rSS
 jrS rSrU =r$ )r   ^   a  A Provider Authentication Policy request, sent from a relying
party to a provider

@ivar preferred_auth_policies: The authentication policies that
    the relying party prefers
@type preferred_auth_policies: [str]

@ivar max_auth_age: The maximum time, in seconds, that the relying
    party wants to allow to have elapsed before the user must
    re-authenticate
@type max_auth_age: int or NoneType

@ivar preferred_auth_level_types: Ordered list of authentication
    level namespace URIs

@type preferred_auth_level_types: [str]
papec                    > [         [        U ]  5         Uc  / nXl        X l        / U l        Ub  U H  nU R                  U5        M     g g r   )superr   r   preferred_auth_policiesmax_auth_agepreferred_auth_level_typesaddAuthLevel)r   r:   r;   r<   
auth_level	__class__s        r   r   Request.__init__s   sU     	gt%'"*&(#'>$(*,'%18
!!*- 9 2r   c                 |    [        U R                  =(       d!    U R                  S L=(       d    U R                  5      $ r   )boolr:   r;   r<   r   s    r   __bool__Request.__bool__   s8    D00 4%%T14335 	5r   c                 Z    XR                   ;  a  U R                   R                  U5        gg)ae  Add an acceptable authentication policy URI to this request

This method is intended to be used by the relying party to add
acceptable authentication types to the request.

@param policy_uri: The identifier for the preferred type of
    authentication.
@see: http://openid.net/specs/openid-provider-authentication-policy-extension-1_0-05.html#auth_policies
N)r:   appendr   
policy_uris     r   addPolicyURIRequest.addPolicyURI   s)     999((//
; :r   c                 |    U R                  X5        XR                  ;  a  U R                  R                  U5        g g r   )r%   r<   rF   )r   r"   r#   s      r   r=   Request.addAuthLevel   s6    6!@!@@++22>B Ar   c                 R   SSR                  U R                  5      0nU R                  b  [        U R                  5      US'   U R                  (       aS  / nU R                   H-  nU R                  U5      nX1SU< 3'   UR                  U5        M/     SR                  U5      US'   U$ )/@see: C{L{Extension.getExtensionArgs}}
        r:    r;   auth_level.ns.r<   )joinr:   r;   strr<   r   rF   )r   ns_argspreferred_typesr"   r#   s        r   getExtensionArgsRequest.getExtensionArgs   s     &sxx0L0L'M
 (&)$*;*;&<GN#** O"&"A"A~6:He67&&u- #B
 58HH_4MG01r   c                     U " 5       nUR                   R                  UR                  5      nUR                   R                  5       nU0 :X  a  gUR	                  X45        U$ )zQInstantiate a Request object from the arguments in a
C{checkid_*} OpenID message
N)messagegetArgsr   	isOpenID1parseExtensionArgs)clsrequestr   args
is_openid1s        r   fromOpenIDRequestRequest.fromOpenIDRequest   sR     u&&t{{3__..0
2:1r   c                    / U l         UR                  S5      nU(       ac  [        U[        5      (       a
  [	        USS9nUR                  S5       H/  nXPR                   ;  d  M  U R                   R                  U5        M1     UR                  S5      nSU l        U(       a   [        U5      U l        UR                  S5      nU(       a`  UR                  5       R                  5       nU H;  n	SU	< 3n
 X   nUc  U(       a  [        S	U	< S
35      eM*  U R                  XY5        M=     gg! [         a    U(       a  e  Nf = f! [         a)    U(       a  U R                  R                  U	5      n NySn N}f = f)a  Set the state of this request to be that expressed in these
PAPE arguments

@param args: The PAPE arguments without a namespace

@param strict: Whether to raise an exception if the input is
    out of spec or otherwise malformed. If strict is false,
    malformed input will be ignored.

@param is_openid1: Whether the input should be treated as part
    of an OpenID1 request

@rtype: None

@raises ValueError: When the max_auth_age is not parseable as
    an integer
r:   zutf-8)encodingrO   r;   Nr<   rP   zpreferred auth level z is not defined in this message)r:   r    
isinstancebytesrR   splitrF   r;   int
ValueErrorstripr   r   r=   )r   r^   r_   strictpolicies_strurimax_auth_age_strr<   aliasesr#   keys              r   r[   Request.parseExtensionArgs   sk   ( (*$xx 9:,.."<'B#))#.:::0077< /
  88N3 $'(8$9! &*XX.J%K"%0668>>@G ,14#)C ;(FK*O P P  %%c1 ! &      #!">>BB5I"	#s*   #D, 5E,E E,E72E76E7c                 T    [        [        U R                  R                  U5      5      $ )aG  Given a list of authentication policy URIs that a provider
supports, this method returns the subsequence of those types
that are preferred by the relying party.

@param supported_types: A sequence of authentication policy
    type URIs that are supported by a provider

@returns: The sub-sequence of the supported types that are
    preferred by the relying party. This list will be ordered
    in the order that the types appear in the supported_types
    sequence, and may be empty if the provider does not prefer
    any of the supported authentication types.

@returntype: [str]
)listfilterr:   __contains__)r   supported_typess     r   preferredTypesRequest.preferredTypes   s)      4//<<oNP 	Pr   )r;   r<   r:   NNNr   F)r/   r0   r1   r2   __doc__ns_aliasr   rC   rI   r=   rU   r`   classmethodr[   rv   r3   __classcell__r?   s   @r   r   r   ^   sY    $ H *.",0. 5
<C
, $$56=2~P Pr   r   c                      ^  \ rS rSrSrSrSU 4S jjrSS jrS rS r	\
" \	SS	9rS
 rS rSS jr\" \5      rS rSrU =r$ )r   i  zA Provider Authentication Policy response, sent from a provider
to a relying party

@ivar auth_policies: List of authentication policies conformed to
    by this OpenID assertion, represented as policy URIs
r7   c                    > [         [        U ]  5         U(       a  Xl        O/ U l        X l        0 U l        Uc  0 nUR                  5        H  u  pEU R                  XE5        M     g r   )r9   r   r   auth_policies	auth_timeauth_levelsr-   setAuthLevel)r   r   r   r   rl   levelr?   s         r   r   Response.__init__   s\    h&(!.!#D"K%++-JCc) .r   c                 B    U R                  X5        X R                  U'   g)aV  Set the value for the given auth level type.

@param level: string representation of an authentication level
    valid for level_uri

@param alias: An optional namespace alias for the given auth
    level URI. May be omitted if the alias is not
    significant. The library will use a reasonable default for
    widely-used auth level types.
N)r%   r   )r   	level_urir   r#   s       r   r   Response.setAuthLevel0  s      		1&+#r   c                      U R                   U   $ )zReturn the auth level for the specified auth level
identifier

@returns: A string that should map to the auth levels defined
    for the auth level type

@raises KeyError: If the auth level type is not present in
    this message
)r   )r   r   s     r   getAuthLevelResponse.getAuthLevel>  s     	**r   c                 `     [        U R                  [        5      5      $ ! [         a     g f = fr   )rg   r   r   r   r   s    r   _getNISTAuthLevelResponse._getNISTAuthLevelJ  s/    	t((566 		s     
--z7Backward-compatibility accessor for the NIST auth level)docc                     U[         :X  a  [        S5      eXR                  ;  a  U R                  R                  U5        gg)ag  Add a authentication policy to this response

This method is intended to be used by the provider to add a
policy that the provider conformed to when authenticating the user.

@param policy_uri: The identifier for the preferred type of
    authentication.
@see: http://openid.net/specs/openid-provider-authentication-policy-extension-1_0-01.html#auth_policies
z4To send no policies, do not set any on the response.N)	AUTH_NONEr)   r   rF   rG   s     r   rI   Response.addPolicyURIT  sE     "FH H ///%%j1 0r   c                     U " 5       nUR                  UR                  5      nUR                  5       nUb  UR                  X45        U$ g)a  Create a C{L{Response}} object from a successful OpenID
library response
(C{L{openid.consumer.consumer.SuccessResponse}}) response
message

@param success_response: A SuccessResponse from consumer.complete()
@type success_response: C{L{openid.consumer.consumer.SuccessResponse}}

@rtype: Response or None
@returns: A provider authentication policy response from the
    data that was supplied with the C{id_res} response or None
    if the provider sent no signed PAPE response arguments.
N)getSignedNSr   rZ   r[   )r\   success_responser   r^   r_   s        r   fromSuccessResponseResponse.fromSuccessResponsee  sM     u  ++DKK8%//1
 ##D5Kr   c                    UR                  S5      nU(       a  UR                  S5      nOU(       a  [        S5      e/ n[        U5      S:  a   U(       a  [        U;   a  [        SU< 35      eSU;   a)  SnU(       a  [        U5      e[
        R                  " USS	9  U Vs/ s H  owS[        4;  d  M  UPM     nnXPl        UR                  5        Hq  u  pUR                  S
5      (       d  M  USS n
U
R                  S5      (       a  M:   USU
< 3   nUc  U(       a  [        SU
< 35      eM_  U R                  XU
5        Ms     UR                  S5      nU(       a4  [        R                  U5      (       a  Xl        gU(       a  [        S5      eggs  snf ! [         a)    U(       a  U R                  R                  U
5      n NSn Nf = f)aA  Parse the provider authentication policy arguments into the
internal state of this object

@param args: unqualified provider authentication policy
    arguments

@param strict: Whether to raise an exception when bad data is
    encountered

@returns: None. The data is parsed into the internal fields of
    this object.
r   rO   zMissing auth_policies   z;Got some auth policies, as well as the special "none" URI: nonez0"none" used as a policy URI (see PAPE draft < 5)   )
stacklevelauth_level.   Nzns.rP   zUndefined auth level alias: r   #auth_time must be in RFC3339 format)r    rf   rh   lenr   warningswarnr   r-   
startswithr   r   r   TIME_VALIDATORmatchr   )r   r^   r_   rj   rk   r   msguro   valr#   rl   r   s                r   r[   Response.parseExtensionArgs  s    xx0(..s3M455M"v)}2L1>B C C ]"DC o%ca0 %
$!&)1D(DA} 	 
 +**,JS~~m,,BC ##E**#U=>C ;(*/*3 4 4  %%c6+ '. HH[)	##I..!* !FGG  =
    #!">>BB5I"	#s$   !F4F	F,GGGc                    [        U R                  5      S:X  a	  S[        0nOSSR                  U R                  5      0nU R                  R                  5        H0  u  p#U R                  U5      nX!SU< 3'   [        U5      USU< 3'   M2     U R                  b>  [        R                  U R                  5      (       d  [        S5      eU R                  US'   U$ )rN   r
   r   rO   rP   r   r   r   )r   r   r   rQ   r   r-   r   rR   r   r   r   rh   )r   rS   
level_typer   r#   s        r   rU   Response.getExtensionArgs  s     t!!"a'G
  $*<*<!=G "&!1!1!7!7!9JNN:.E6@G%2336u:Gu/0 ":
 >>%!''77 !FGG#'>>GK r   )r   r   r   rx   r   ry   )r/   r0   r1   r2   rz   r{   r   r   r   r   propertynist_auth_levelrI   r   r[   r|   rU   r3   r}   r~   s   @r   r   r     s`     H* ,
+ EGO2"8BHH &&9: r   r   )rz   __all__openid.extensionr   r   rer   r   r   r   r   compiler   r   r	   r   r   r   r4   r   r   <module>r      s   	 '  		6 L  C  I  ; 
 CDT:2'I 2'jrPm rPj H} HV r   