509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
í«„^�  ã               @   sz   d dl Z ddlmZmZ ddlmZmZmZmZ G dd„ dƒZ	G dd„ dƒZ
G d	d
„ d
ƒZG dd„ dƒZG dd„ dƒZdS )é    Né   )ÚCriteriaDescriptorÚCriteriaSetDescriptor)Úmatch_in_setÚmatch_regexÚmatch_rangeÚmatch_regex_or_setc               @   s,   e Zd ZdZedƒZdZdd„ Zdd„ ZdS )	Ú
MatchAliasz'Mixin for matching an object's aliases.Úalias_regexFc             C   s   |j dj| ƒƒ dS )z+Emit log debugging info for alias matching.z(Alias: {0.alias}, regex: {0.alias_regex}N)ÚdebugÚformat)ÚselfÚlog© r   ú/usr/lib64/python3.6/mixins.pyÚ_match_alias_debug"   s    zMatchAlias._match_alias_debugc             C   s   | j s
dS t|jƒ | j | jƒS )z‡
        Match the alias criteria

        Parameter:
        obj     An object with an alias generator method named "aliases"
        T)Úaliasr   Úaliasesr
   )r   Úobjr   r   r   Ú_match_alias&   s    zMatchAlias._match_aliasN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r
   r   r   r   r   r   r   r	      s
   r	   c               @   sd   e Zd ZdZeddƒZdZeddƒZdZeddƒZ	dZ
ed	d
�ZdZdZdZdZdd„ Zdd„ ZdS )ÚMatchContextaL  
    Mixin for matching contexts.

    Class attributes:
    user            The user to match in the context.
    user_regex      If true, regular expression matching
                    will be used on the user.
    role            The role to match in the context.
    role_regex      If true, regular expression matching
                    will be used on the role.
    type_           The type to match in the context.
    type_regex      If true, regular expression matching
                    will be used on the type.
    range_          The range to match in the context.
    range_subset    If true, the criteria will match if it
                    is a subset of the context's range.
    range_overlap   If true, the criteria will match if it
                    overlaps any of the context's range.
    range_superset  If true, the criteria will match if it
                    is a superset of the context's range.
    range_proper    If true, use proper superset/subset
                    on range matching operations.
                    No effect if not using set operations.
    Ú
user_regexZlookup_userFÚ
role_regexZlookup_roleÚ
type_regexZlookup_typeZlookup_range)Zlookup_functionc             C   sD   |j dj| ƒƒ |j dj| ƒƒ |j dj| ƒƒ |j dj| ƒƒ dS )z-Emit log debugging info for context matching.z'User: {0.user!r}, regex: {0.user_regex}z'Role: {0.role!r}, regex: {0.role_regex}z(Type: {0.type_!r}, regex: {0.type_regex}z�Range: {0.range_!r}, subset: {0.range_subset}, overlap: {0.range_overlap}, superset: {0.range_superset}, proper: {0.range_proper}N)r   r   )r   r   r   r   r   Ú_match_context_debug\   s
    z!MatchContext._match_context_debugc             C   sˆ   | j rt|j | j | jƒ rdS | jr<t|j| j| jƒ r<dS | jrZt|j| j| jƒ rZdS | jr„t|j| j| j	| j
| j| jƒ r„dS dS )z©
        Match the context criteria.

        Parameter:
        obj     An object with context attributes "user", "role",
                "type_" and "range_".
        FT)Úuserr   r   Úroler   Útype_r   Úrange_r   Úrange_subsetÚrange_overlapÚrange_supersetÚrange_proper)r   Úcontextr   r   r   Ú_match_contextd   s0    	



zMatchContext._match_contextN)r   r   r   r   r   r   r   r    r   r!   r   r"   r$   r#   r%   r&   r   r(   r   r   r   r   r   5   s   



r   c               @   s0   e Zd ZdZedƒZdZdZdd„ Zdd„ Z	dS )	Ú	MatchNamez=Mixin for matching an object's name with alias dereferencing.Ú
name_regexFc             C   s   |j dj| ƒƒ dS )z)Log debugging messages for name matching.z?Name: {0.name!r}, regex: {0.name_regex}, deref: {0.alias_deref}N)r   r   )r   r   r   r   r   Ú_match_name_debug“   s    zMatchName._match_name_debugc             C   sH   | j s
dS | jr4t|| j | jƒp2t|jƒ | j | jƒS t|| j | jƒS dS )z&Match the object to the name criteria.TN)ÚnameÚalias_derefr   r*   r   r   )r   r   r   r   r   Ú_match_name—   s    zMatchName._match_nameN)
r   r   r   r   r   r,   r*   r-   r+   r.   r   r   r   r   r)   ‹   s   r)   c               @   s.   e Zd ZdZeddƒZdZdd„ Zdd„ Zd	S )
ÚMatchObjClassz%Mixin for matching an object's class.Útclass_regexZlookup_classFc             C   s   |j dj| ƒƒ dS )z0Emit log debugging info for permission matching.z,Class: {0.tclass!r}, regex: {0.tclass_regex}N)r   r   )r   r   r   r   r   Ú_match_object_class_debug«   s    z'MatchObjClass._match_object_class_debugc             C   s6   | j s
dS | jr&t| j jt|j ƒƒƒS |j | j kS dS )z�
        Match the object class criteria

        Parameter:
        obj     An object with an object class attribute named "tclass"
        TN)Útclassr0   ÚboolÚsearchÚstr)r   r   r   r   r   Ú_match_object_class¯   s
    z!MatchObjClass._match_object_classN)	r   r   r   r   r   r2   r0   r1   r6   r   r   r   r   r/   ¤   s
   
r/   c               @   s4   e Zd ZdZedƒZdZdZdZdd„ Z	dd„ Z
dS )	ÚMatchPermissionz+Mixin for matching an object's permissions.Úperms_regexFc             C   s   |j dj| ƒƒ dS )z0Emit log debugging info for permission matching.z[Perms: {0.perms!r}, regex: {0.perms_regex}, eq: {0.perms_equal}, subset: {0.perms_subset!r}N)r   r   )r   r   r   r   r   Ú_match_perms_debugÉ   s    z"MatchPermission._match_perms_debugc             C   s6   | j s
dS | jr|j | j kS t|j | j | j| jƒS dS )z‘
        Match the permission criteria

        Parameter:
        obj     An object with a permission set class attribute named "perms"
        TN)ÚpermsÚperms_subsetr   Úperms_equalr8   )r   r   r   r   r   Ú_match_permsÎ   s
    zMatchPermission._match_permsN)r   r   r   r   r   r:   r<   r8   r;   r9   r=   r   r   r   r   r7   À   s   r7   )ÚreZdescriptorsr   r   Úutilr   r   r   r   r	   r   r)   r/   r7   r   r   r   r   Ú<module>   s   V