
    ?De                        d Z ddgZddlZddlmZ ddlmZmZmZm	Z	 ddl
mZmZmZmZmZ ddlmZmZ  G d	 d
ej                  Z G d dej                  Z G d dej                  Z G d de          Zeeej        <    G d dej                  Z G d dej                  Z G d de          Zeeej        <   dS )z
ldap.controls.vlv - classes for Virtual List View
(see draft-ietf-ldapext-ldapv3-vlv)

See https://www.python-ldap.org/ for project details.
VLVRequestControlVLVResponseControl    N)
LDAPObject)RequestControlResponseControlKNOWN_RESPONSE_CONTROLSDecodeControlTuples)univ	namedtypetagnamedval
constraint)encoderdecoderc                      e Zd Zej        j                             ej        ej	        ej
        d                    Z ej         ej        d ej                               ej        d ej                                        ZdS )ByOffsetTyper   offsetcontentCountN)__name__
__module____qualname__r
   SequencetagSettagImplicitlyr   TagtagClassContexttagFormatSimpler   
NamedTypes	NamedTypeIntegercomponentType     /./ldap/controls/vlv.pyr   r      s        ]!//CGC')<a@@B BF(I(I,$,..99I??A AMMMr#   r   c                       e Zd Z ej         ej        d e                       ej        d ej                    	                     e
j        e
j        e
j        d                                        ZdS )
TargetTypebyOffsetgreaterThanOrEqual   )implicitTagN)r   r   r   r   r   r   r   r
   OctetStringsubtyper   r   r   r   r!   r"   r#   r$   r&   r&      s        (I(I
LLNN;;I 46Fd6F6H6H6P6P#CGC$7', , 7Q 7- 7- . ./ /MMMr#   r&   c            
       
   e Zd Z ej         ej        d ej                               ej        d ej                               ej        d e                       ej	        d ej
                                        ZdS )VirtualListViewRequestTypebeforeCount
afterCounttarget	contextIDN)r   r   r   r   r   r   r
   r    r&   OptionalNamedTyper+   r!   r"   r#   r$   r.   r.   &   s        (I(I|t|~~>>Ildlnn==I**,,77'I'5ET5E5G5GHH	J JMMMr#   r.   c                   .    e Zd ZdZ	 	 	 	 	 	 	 ddZd ZdS )r   z2.16.840.1.113730.3.4.9Fr   Nc                     t          j        | | j        |           |||sJ t          d                      || _        || _        || _        || _        || _        || _	        d S )NzSoffset and content_count must be set together or greater_than_or_equal must be used)
r   __init__controlType
ValueErrorbefore_countafter_countr   content_countgreater_than_or_equal
context_id)selfcriticalityr9   r:   r   r;   r<   r=   s           r$   r6   zVLVRequestControl.__init__1   s     	T%5kBBB"}'@$ (A'@e  (A'@'@
 )&*%:"$r#   c                 <   t                      }|                    d| j                   |                    d| j                   | j        p| j        it                      }|                    d| j                   |                    d| j                   t                      }|                    d|           n8| j        r*t                      }|                    d| j                   nt          |                    d|           t          j        |          S )Nr/   r0   r   r   r'   r(   r1   )r.   setComponentByNamer9   r:   r   r;   r   r&   r<   NotImplementedErrorr   encode)r>   p	by_offsetr1   s       r$   encodeControlValuez$VLVRequestControl.encodeControlValueH   s   &((	]D,=>>>	\4+;<<<;"t'9'E$I((4;???((9KLLL\\F%%j)<<<<' 	&\\F%%&:.0 0 0 0 &%	Xv...~a   r#   )Fr   r   NNNN)r   r   r   r7   r6   rF   r"   r#   r$   r   r   .   sS        +K "% % % %.! ! ! ! !r#   c                   @    e Zd Z ej        ddddddddd	d

  
        ZdS )VirtualListViewResultType)successr   )operationsErrorr)   )protocolError   )unwillingToPerform5   )insufficientAccessRights2   )adminLimitExceeded   )innapropriateMatching   )sortControlMissing<   )offsetRangeError=   )otherP   N)r   r   r   r   NamedValuesnamedValuesr"   r#   r$   rH   rH   ^   s@        &(&%#)/),)' KKKr#   rH   c            
       
   e Zd Z ej         ej        d ej                               ej        d ej                               ej        d e                       ej	        d ej
                                        ZdS )VirtualListViewResponseTypetargetPositionr   virtualListViewResultr2   N)r   r   r   r   r   r   r
   r    rH   r3   r+   r!   r"   r#   r$   r^   r^   m   s        (I(I 0,$,..AAI??I 7))++- -'I'5ET5E5G5GHHJ JMMMr#   r^   c                        e Zd ZdZddZd ZdS )r   z2.16.840.1.113730.3.4.10Fc                 <    t          j        | | j        |           d S )N)r   r6   r7   )r>   r?   s     r$   r6   zVLVResponseControl.__init__y   s      d&6{CCCCCr#   c                 @   t          j        |t                                \  }}|r
J d            t          |                    d                    | _        t          |                    d                    | _        |                    d          }t          |          | _        |                    d          }|                                rt          |          | _
        nd | _
        | j        | _        | j        | _        | j        | _        | j
        | _        d S )N)asn1Speczall data could not be decodedr_   r   r`   r2   )r   decoder^   intgetComponentByNamer_   r   r`   hasValuestrr2   target_positionr;   resultr=   )r>   encodedrD   restvirtual_list_view_resultr=   s         r$   decodeControlValuez%VLVResponseControl.decodeControlValue|   s   .3N3P3PQQQ4888888!!"6"67G"H"HII 4 4^ D DEE#$#7#78O#P#P %()A%B%B"))+66
   	" __DNN!DN#2!.0.r#   N)F)r   r   r   r7   r6   ro   r"   r#   r$   r   r   v   s@        ,KD D D D) ) ) ) )r#   )__doc____all__ldapldap.ldapobjectr   ldap.controlsr   r   r   r	   pyasn1.typer
   r   r   r   r   pyasn1.codec.berr   r   r   r   Choicer&   r.   r   r7   
EnumeratedrH   r^   r   r"   r#   r$   <module>ry      s/    
  & & & & & &6 6 6 6 6 6 6 6 6 6 6 6 C B B B B B B B B B B B B B - - - - - - - -A A A A A4= A A A/ / / / / / / /J J J J J J J J+! +! +! +! +! +! +! +!Z :K )5 6       J J J J J$- J J J) ) ) ) ) ) ) )0 ;M *6 7 7 7r#   