
­­­­­­­­­­­­­­­­­­
<!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}zRange: {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rt|j| j| j	| j
| j| j rd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