Spade

Mini Shell

Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/certbot/_internal/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/usr/lib/python2.7/site-packages/certbot/_internal/account.pyc

�
���_c@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	Z
ddlZddlZddl
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZeje�Zdefd
��YZ
dej!fd��YZ"dej#fd��YZ$dej!fd��YZ%dS(s!Creates
ACME accounts for
server.i����N(t
serialization(tfields(tmessages(t
ClientBase(terrors(t
interfaces(tutil(t	constants(tostAccountcBsTeZdZdejfd��YZdd�Zed��Z	d�Z
d�ZRS(s�ACME protocol registration.

    :ivar .RegistrationResource regr: Registration Resource
    :ivar .JWK key: Authorized Account Key
    :ivar .Meta: Account metadata
    :ivar str id: Globally unique account identifier.

    tMetacBsAeZdZejd�Zejd�Zejdde	�Z
RS(s�Account metadata

        :ivar datetime.datetime creation_dt: Creation date and time (UTC).
        :ivar str creation_host: FQDN of host, where account has been
created.
        :ivar str register_to_eff: If not None, Certbot will register the
provided
                                        email during the account
registration.

        .. note:: ``creation_dt`` and ``creation_host`` are useful in
            cross-machine migration scenarios.

       
tcreation_dtt
creation_hosttregister_to_efft	omitempty(t__name__t
__module__t__doc__tacme_fieldstRFC3339FieldRtjosetFieldRtTrueR
(((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR
%scCs�||_||_|dkr`|jdtjjdtj�jdd�dt	j
�dd�n||_ytj
�}Wn&tk
r�tjddt�}nX|j|jjj�jd	tjjd
tjj��|j�|_dS(NRttztmicrosecondiRR
tmd5tusedforsecuritytencodingtformat(tkeytregrtNoneR
tdatetimetnowtpytztUTCtreplacetsockettgetfqdntmetathashlibRt
ValueErrortnewtFalsetupdatet
public_keytpublic_bytesRtEncodingtPEMtPublicFormattSubjectPublicKeyInfot	hexdigesttid(tselfRRR'thasher((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyt__init__5s		W
cCs/djtj|jj�|jj|jd
�S(s3Short account identification string, useful for UI.s
{1}@{0}
({2})i(Rt	pyrfc3339tgenerateR'RRR4(R5((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pytslugPscCs%dj|jj|j|j|j�S(Ns<{0}({1},
{2},
{3})>(Rt	__class__RRR4R'(R5((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyt__repr__VscCsFt||j�oE|j|jkoE|j|jkoE|j|jkS(N(t
isinstanceR;RRR'(R5tother((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyt__eq__Zs$N(RRRRtJSONObjectWithFieldsR
RR7tpropertyR:R<R?(((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR	s	tAccountMemoryStoragecBs5eZdZdd�Zd�Zd�Zd�ZRS(sIn-memory
account
storage.cCs|dk	r|ni|_dS(N(Rtaccounts(R5tinitial_accounts((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR7cscCsttj|j��S(N(tlisttsixt
itervaluesRC(R5((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pytfind_allfscCs<|j|jkr(tjd|j�n||j|j<dS(NsOverwriting
account:
%s(R4RCtloggertdebug(R5taccounttclient((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pytsaveiscCs6y|j|SWn
tk
r1tj|��nXdS(N(RCtKeyErrorRtAccountNotFound(R5t
account_id((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pytloadns
N(RRRRR7RHRMRQ(((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyRB`s
		t$RegistrationResourceWithNewAuthzrURIcBseZdZejd�ZRS(sfA
backwards-compatible RegistrationResource with a new-authz URI.

       Hack: Certbot versions pre-0.11.1 expect to load
       new_authzr_uri as part of the account. Because people
       sometimes switch between old and new versions, we will
       continue to write out this field for some time so older
       clients don't crash in that scenario.
   
tnew_authzr_uri(RRRRRRS(((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyRRtstAccountFileStoragecBs�eZdZd�Zd�Zd�Zed��Zed��Zed��Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(sMAccounts
file storage.

    :ivar .IConfig config: Client configuration

   
cCs)||_tj|jd|jj�dS(Ni�(tconfigRtmake_or_verify_dirtaccounts_dirtstrict_permissions(R5RU((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR7�s	cCs|j||jj�S(N(t!_account_dir_path_for_server_pathRUtserver_path(R5RP((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyt_account_dir_path�scCs%|jj|�}tjj||�S(N(RUtaccounts_dir_for_server_pathRtpathtjoin(R5RPRZRW((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyRY�scCstjj|d�S(Ns	regr.json(RR]R^(tclstaccount_dir_path((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyt
_regr_path�scCstjj|d�S(Nsprivate_key.json(RR]R^(R_R`((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyt	_key_path�scCstjj|d�S(Ns	meta.json(RR]R^(R_R`((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyt_metadata_path�scCs	|jj|�}ytj|�}Wntk
r9gSXg}xU|D]M}y|j|j||��WqGtjk
r�t	j
ddt�qGXqGW|r|tj
krtj
|}|j|�}|r�y|j||�Wq�tk
r�gSXn|}n|S(NsAccount loading
problemtexc_info(RUR\RtlistdirtOSErrortappendt_load_for_server_pathRtAccountStorageErrorRIRJRRtLE_REUSE_SERVERSt_find_all_for_server_patht_symlink_to_accounts_dir(R5RZRWt
candidatesRCRPtprev_server_patht
prev_accounts((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyRk�s*



	cCs|j|jj�S(N(RkRURZ(R5((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyRH�scCs8|j||�}|j||�}tj||�dS(N(RYRtsymlink(R5RnRZRPtprev_account_dirtnew_account_dir((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyt_symlink_to_account_dir�scCsg|jj|�}tjj|�r4tj|�n
tj|�|jj|�}tj||�dS(N(RUR\RR]tislinktunlinktrmdirRp(R5RnRZRWRq((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyRl�s
cCs�|j||�}tjj|�s�|tjkr�tj|}|j||�}|jj|�}tj	|�r�|j
|||�n|j||�|Stj
d|��ny�t|j|���}tjj|j��}WdQXt|j|���}	tjj|	j��}
WdQXt|j|���}tjj|j��}WdQXWn"tk
r}}
tj|
��nXt||
|�S(NsAccount at %s does not
exist(RYRR]tisdirRRjRhRUR\ReRsRlRROtopenRaRtRegistrationResourcet
json_loadstreadRbRtJWKRcR	R
tIOErrorRi(R5RPRZR`Rntprev_loaded_accountRWt	regr_fileRtkey_fileRt
metadata_fileR'terror((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyRh�s,
"cCs|j||jj�S(N(RhRURZ(R5RP((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyRQ�scCsoyF|j|�}|j||�|j||�|j|||�Wn"tk
rj}tj|��nXdS(s�Create a new account.

        :param Account account: account to create
        :param ClientBase client: ACME client associated to the account

       
N(t_preparet_createt_update_metat_update_regrR}RRi(R5RKRLtdir_pathR�((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyRM�scCsOy&|j|�}|j|||�Wn"tk
rJ}tj|��nXdS(s�Update the registration resource.

        :param Account account: account to update
        :param ClientBase client: ACME client associated to the account

       
N(R�R�R}RRi(R5RKRLR�R�((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pytupdate_regr�s
cCsLy#|j|�}|j||�Wn"tk
rG}tj|��nXdS(sVUpdate the meta resource.

        :param Account account: account to update

       
N(R�R�R}RRi(R5RKR�R�((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pytupdate_metas
cCs||j|�}tjj|�s7tjd|��n|j||jj�tj	|jj
�sx|j|jj�ndS(snDelete registration info from disk

        :param account_id: id of account which should be deleted

        sAccount at %s does not
existN(R[RR]RwRROt#_delete_account_dir_for_server_pathRURZReRWt$_delete_accounts_dir_for_server_path(R5RPR`((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pytdeletescCs8tj|j|�}|j||�}tj|�dS(N(t	functoolstpartialRYt!_delete_links_and_find_target_dirtshutiltrmtree(R5RPRZt	link_functnonsymlinked_dir((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR�$scCs/|jj}|j||�}tj|�dS(N(RUR\R�RRv(R5RZR�R�((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR�)sc
Cs�||�}i}x"tjD]}||tj|<qWt}xq|r�t}||kr@||}||�}tjj|�r�tj|�|kr�t}|}|}q�q@q@Wx8tjj|�r�tj|�}	tj|�|	}q�W|S(s/Delete
symlinks and return the nonsymlinked directory path.

        :param str server_path: file path based on server
        :param callable link_func: callable that returns possible links
            given a server_path

        :returns: the final, non-symlinked target
        :rtype: str

        (	RRjRR+RR]RttreadlinkRu(
R5RZR�R�treused_serverstktpossible_next_linktnext_server_patht
next_dir_pathttarget((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR�.s&	
'

cCs/|j|j�}tj|d|jj�|S(Ni�(R[R4RRVRURX(R5RKR`((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR�UscCsDtj|j|�ddd��}|j|jj��WdQXdS(Ntwtchmodi(Rt	safe_openRbtwriteRt
json_dumps(R5RKR�R�((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR�[s$cCs�t|j|�d��w}|j}t|jd�r]td|jjdid|j�}ntj	did|j�}|j
|j��WdQXdS(NR�s	new-authzRStbodyturi(RxRaRthasattrt	directoryRRt	new_authzR�RRyR�R�(R5RKtacmeR�RR((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR�`s		cCs;t|j|�d��}|j|jj��WdQXdS(NR�(RxRcR�R'R�(R5RKR�R�((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyR�ss(RRRR7R[RYtclassmethodRaRbRcRkRHRsRlRhRQRMR�R�R�R�R�R�R�R�R�R�(((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyRTs0													
				'			(&RR
R�R(tloggingR�R%tcryptography.hazmat.primitivesRtjosepyRR8R"RFR�RRRtacme.clientRtcertbotRRRtcertbot._internalRtcertbot.compatRt	getLoggerRRItobjectR	tAccountStorageRBRyRRRT(((s=/usr/lib/python2.7/site-packages/certbot/_internal/account.pyt<module>s0E