
    ?De                        d Z ddlmZ ddlZej        ek    sJ  ede dej         d                      ddlZddlmZ g dZi Z	 G d	 d
          Z
 G d d          Z G d de
e          Zd ZddZddlT ddlT dS )z
controls.py - support classes for LDAP controls

See https://www.python-ldap.org/ for details.

Description:
The ldap.controls module provides LDAPControl classes.
Each class provides support for a certain control.
    )__version__Nzldap z and _ldap z version mismatch!)PyAsn1Error)KNOWN_RESPONSE_CONTROLSAssertionControlBooleanControlLDAPControlManageDSAITControlMatchedValuesControlRelaxRulesControlRequestControlResponseControlSimplePagedResultsControlValueLessRequestControlRequestControlTuplesDecodeControlTuplesc                        e Zd ZdZddZd ZdS )r   a=  
  Base class for all request controls

  controlType
      OID as string of the LDAPv3 extended request control
  criticality
      sets the criticality of the control (boolean)
  encodedControlValue
      control value of the LDAPv3 extended request control
      (here it is the BER-encoded ASN.1 control value)
  NFc                 0    || _         || _        || _        d S N)controlTypecriticalityencodedControlValue)selfr   r   r   s       /./ldap/controls/__init__.py__init__zRequestControl.__init__9   s     "D"D2D    c                     | j         S )z
    sets class attribute encodedControlValue to the BER-encoded ASN.1
    control value composed by class attributes set before
    r   )r   s    r   encodeControlValuez!RequestControl.encodeControlValue>   s    
 ##r   )NFN)__name__
__module____qualname____doc__r   r    r   r   r   r   ,   sA        
 
3 3 3 3
$ $ $ $ $r   r   c                        e Zd ZdZddZd ZdS )r   z
  Base class for all response controls

  controlType
      OID as string of the LDAPv3 extended response control
  criticality
      sets the criticality of the received control (boolean)
  NFc                 "    || _         || _        d S r   )r   r   )r   r   r   s      r   r   zResponseControl.__init__P   s    "D"Dr   c                     || _         dS )zc
    decodes the BER-encoded ASN.1 control value and sets the appropriate
    class attributes
    Nr   )r   r   s     r   decodeControlValuez"ResponseControl.decodeControlValueT   s    
  3Dr   )NF)r   r    r!   r"   r   r'   r#   r   r   r   r   F   sA         # # # #3 3 3 3 3r   r   c                       e Zd ZdZddZdS )r   zp
  Base class for combined request/response controls mainly
  for backward-compatibility to python-ldap 2.3.x
  NFc                 >    || _         || _        || _        || _        d S r   )r   r   controlValuer   )r   r   r   r*   r   s        r   r   zLDAPControl.__init__b   s(    "D"D$D2Dr   )NFNN)r   r    r!   r"   r   r#   r   r   r   r   \   s2         
3 3 3 3 3 3r   r   c                 &    | dS d | D             }|S )z
  Return list of readily encoded 3-tuples which can be directly
  passed to C module _ldap

  ldapControls
      sequence-type of RequestControl objects
  Nc                 P    g | ]#}|j         |j        |                                f$S r#   )r   r   r   ).0cs     r   
<listcomp>z(RequestControlTuples.<locals>.<listcomp>t   s?       
 	}Q]1#7#7#9#9:  r   r#   )ldapControlsresults     r   r   r   i   s4     4   F Mr   c                 Z   |pt           }g }| pg D ]\  }}}	  ||                     }||c|_        |_        	 |                    |           |                    |           R# t
          $ r |r Y aw xY w# t          $ r) |r$t          j        dt          |          z            Y w xY w|S )a  
  Returns list of readily decoded ResponseControl objects

  ldapControlTuples
      Sequence-type of 3-tuples returned by _ldap.result4() containing
      the encoded ASN.1 control values of response controls.
  knownLDAPControls
      Dictionary mapping extended control's OID to ResponseControl class
      of response controls known by the application. If None
      ldap.controls.KNOWN_RESPONSE_CONTROLS is used here.
  zAReceived unexpected critical response control with controlType %s)
r   r   r   r'   appendr   KeyErrorldapUNAVAILABLE_CRITICAL_EXTENSIONrepr)ldapControlTuplesknownLDAPControlsr1   r   r   r   controls          r   r   r   {   s6    (B+B&5F5L"  1k+1.!+.00g
 1<K-g'-""#6777
 	g	     	
	 	  M M M	 M12uy}  J  zK  zK  3L  M  M  	MM MM 
-s"   A5A""A21A250B('B()*r   )r"   ldap.pkginfor   _ldapImportErrorr5   pyasn1.errorr   __all__r   r   r   r   r   r   ldap.controls.simpleldap.controls.libldapr#   r   r   <module>rC      sb    % $ $ $ $ $ +%%%{X;XX53DXXXYY &%%  $ $ $ $ $ $  &  $ $ $ $ $ $ $ $43 3 3 3 3 3 3 3,
3 
3 
3 
3 
3. 
3 
3 
3  $   B # " " " # # # # # #r   