HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/ipalib/__pycache__/krb_utils.cpython-39.pyc
a

}�f_�@s�ddlZddlZddlZddlmZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZeeZdZdZe�d�Zdd�Zdd�Zdd�Zdd�Zdd�Zd!dd�Zd"dd�Zd#dd �ZdS)$�N)�errorsl�:�-l�:�-l:�-l:�-l :�-l�:�-l�:�-l�:�-l�:�-l:�-i i,z%m/%d/%y %H:%M:%Sz^((\w+):)?(.+)cCsPt�|�}|r@|�d�}|�d�}|dur0d}n|��}||fStd|��dS)a�
    Given a Kerberos ccache name parse it into it's scheme and
    location components. Currently valid values for the scheme
    are:

      * FILE
      * MEMORY

    The scheme is always returned as upper case. If the scheme
    does not exist it defaults to FILE.

    :parameters:
      ccache_name
        The name of the Kerberos ccache.
    :returns:
      A two-tuple of (scheme, ccache)
    ��N�FILEzInvalid ccache name = "%s")�ccache_name_re�search�group�upper�
ValueError)�ccache_name�match�scheme�location�r�4/usr/lib/python3.9/site-packages/ipalib/krb_utils.py�krb5_parse_ccache6s


rcCsd|��|fS)Nz%s:%s)r	)r
�namerrr�krb5_unparse_ccacheUsrcCsd|||fS)a�

    Given a Kerberos service principal name, the host where the
    service is running and a Kerberos realm return the Kerberos V5
    service principal name.

    :parameters:
      service
        Service principal name.
      host
        The DNS name of the host where the service is located.
      realm
        The Kerberos realm the service exists in.
    :returns:
      Kerberos V5 service principal name.
    z%s/%s@%sr)Zservice�host�realmrrr�"krb5_format_service_principal_nameYsrcCstd||�S)z�
    Given a Kerberos realm return the Kerberos V5 TGT name.

    :parameters:
      realm
        The Kerberos realm the TGT exists in.
    :returns:
      Kerberos V5 TGT name.
    Zkrbtgt)r)rrrr�krb5_format_tgt_principal_namels
rcCst�tt�|��S)z�
    Given a UNIX timestamp format it into a string in the same
    manner the MIT Kerberos library does. Kerberos timestamps are
    always in local time.

    :parameters:
      timestamp
        Unix timestamp
    :returns:
      formated string
    )�time�strftime�
krb5_time_fmt�	localtime)Z	timestamprrr�krb5_format_timexsrcCs d}|rd|i}tjd||d�S)a�
    Obtains GSSAPI credentials with given principal name from ccache. When no
    principal name specified, it retrieves the default one for given
    credentials cache.

    :parameters:
      name
        gssapi.Name object specifying principal or None for the default
      ccache_name
        string specifying Kerberos credentials cache name or None for the
        default
    :returns:
      gssapi.Credentials object
    NZccacheZinitiate)�usager�store)�gssapiZCredentials)rrrrrr�get_credentials�sr c
CsTzt|d�}t|j�WStjjyN}ztjt|�d��WYd}~n
d}~00dS)aY
    Gets default principal name from given credentials cache.

    :parameters:
      ccache_name
        string specifying Kerberos credentials cache name or None for the
        default
    :returns:
      Default principal name as string
    :raises:
      errors.CCacheError if the principal cannot be retrieved from given
      ccache
    )r)�messageN)r �strrr�
exceptions�GSSErrorrZCCacheError)r�creds�errr�
get_principal�s

r'cCs>z t||d�}|jdkr|WSWntjjy8YdS0dS)a!
    Obtains GSSAPI credentials with principal name from ccache. When no
    principal name specified, it retrieves the default one for given
    credentials cache. When the credentials cannot be retrieved or aren't valid
    it returns None.

    :parameters:
      name
        gssapi.Name object specifying principal or None for the default
      ccache_name
        string specifying Kerberos credentials cache name or None for the
        default
    :returns:
      gssapi.Credentials object or None if valid credentials weren't found
    )rrrN)r Zlifetimerr#r$)rrr%rrr�get_credentials_if_valid�s

r()NN)N)NN)r�rerZipalibrZKRB5_CC_NOTFOUNDZKRB5_FCC_NOFILEZKRB5KDC_ERR_C_PRINCIPAL_UNKNOWNZKRB5KDC_ERR_S_PRINCIPAL_UNKNOWNZKRB5KRB_AP_ERR_TKT_EXPIREDZ
KRB5_FCC_PERMZKRB5_CC_FORMATZKRB5_REALM_CANT_RESOLVEZKRB5_KDC_UNREACHZKRB5KDC_ERR_SVC_UNAVAILABLEZGSSPROXY_MAP_ERROR_BASEZGSSPROXY_KRB5_FCC_NOFILEZkrb_ticket_expiration_thresholdr�compilerrrrrrr r'r(rrrr�<module>s4

%