o ckF[ @sxddlZddlZddlZddlmZGdddeZGdddeZGdddeZ Gd d d eZ Gd d d eZ dS) N)jsonc@s\eZdZdZdddZeddZeddZd d Zd d Z d dZ ddZ dddZ dS) Credentialsa' :ivar access_key: The AccessKeyID. :ivar secret_key: The SecretAccessKey. :ivar session_token: The session token that must be passed with requests to use the temporary credentials :ivar expiration: The timestamp for when the credentials will expire NcC(||_d|_d|_d|_d|_d|_dSN)parent access_key secret_key session_token expiration request_idselfrr6/usr/lib/python3/dist-packages/boto/sts/credentials.py__init__'  zCredentials.__init__cCs t|}|}|j||S)z Create and return a new Session Token based on the contents of a JSON document. :type json_doc: str :param json_doc: A string containing a JSON document with a previously saved Credentials object. )rloads__dict__update)clsjson_docdtokenrrr from_json/s  zCredentials.from_jsoncCs"t|}|}|||S)a- Create and return a new Session Token based on the contents of a previously saved JSON-format file. :type file_path: str :param file_path: The fully qualified path to the JSON-format file containing the previously saved Session Token information. )openreadcloser)r file_pathfprrrrload>s  zCredentials.loadcCdSrrr nameattrs connectionrrr startElementMzCredentials.startElementcCs`|dkr ||_dS|dkr||_dS|dkr||_dS|dkr$||_dS|dkr-||_dS dS)N AccessKeyIdSecretAccessKey SessionToken Expiration RequestIdrrr r r r r"valuer$rrr endElementPs     zCredentials.endElementcCs|j|j|j|j|jdS)zm Return a Python dict containing the important information about this Session Token. r,r,)r rrrto_dict^s zCredentials.to_dictcCs2t|d}t|||t|ddS)a Persist a Session Token to a file in JSON format. :type path: str :param path: The fully qualified path to the file where the the Session Token data should be written. Any previous data in the file will be overwritten. To help protect the credentials contained in the file, the permissions of the file will be set to readable/writable by owner only. wiN)rrdumpr0roschmod)r rrrrrsaveis zCredentials.savercCs@tj}|r|tj|d}tj|j}||}|dkS)a Checks to see if the Session Token is expired or not. By default it will check to see if the Session Token is expired as of the moment the method is called. However, you can supply an optional parameter which is the number of seconds of offset into the future for the check. For example, if you supply a value of 5, this method will return a True if the Session Token will be expired 5 seconds from this moment. :type time_offset_seconds: int :param time_offset_seconds: The number of seconds into the future to test the Session Token for expiration. )secondsr)datetimeutcnow timedeltabotoutilsparse_tsr total_seconds)r time_offset_secondsnowtsdeltarrr is_expiredys  zCredentials.is_expiredr)r) __name__ __module__ __qualname____doc__r classmethodrrr%r/r0r5rBrrrrrs    rc@*eZdZdZd ddZddZddZdS) FederationTokenah :ivar credentials: A Credentials object containing the credentials. :ivar federated_user_arn: ARN specifying federated user using credentials. :ivar federated_user_id: The ID of the federated user using credentials. :ivar packed_policy_size: A percentage value indicating the size of the policy in packed form NcCrr)r credentialsfederated_user_arnfederated_user_idpacked_policy_sizer r rrrrrzFederationToken.__init__cCs|dkr t|_|jSdS)Nr)rrJr!rrrr%szFederationToken.startElementcCsR|dkr ||_dS|dkr||_dS|dkrt||_dS|dkr&||_dS dS)NArnFederatedUserIdPackedPolicySizer+)rKrLintrMr r-rrrr/s   zFederationToken.endElementrrCrDrErFrr%r/rrrrrIs   rIc@rH) AssumedRolezt :ivar user: The assumed role user. :ivar credentials: A Credentials object containing the credentials. NcCs||_||_||_dSr) _connectionrJuser)r r$rJrUrrrrs zAssumedRole.__init__cCs0|dkr t|_|jS|dkrt|_|jSdS)NrAssumedRoleUser)rrJUserrUr!rrrr%szAssumedRole.startElementcCr rrr-rrrr/r&zAssumedRole.endElement)NNNrRrrrrrSs   rSc@rH) rWzy :ivar arn: The arn of the user assuming the role. :ivar assume_role_id: The identifier of the assumed role. NcC||_||_dSrarnassume_role_id)r rZr[rrrr z User.__init__cCr rrr!rrrr%r&zUser.startElementcC(|dkr ||_dS|dkr||_dSdS)NrN AssumedRoleIdrYr-rrrr/   zUser.endElementNNrRrrrrrW   rWc@rH) DecodeAuthorizationMessagezw :ivar request_id: The request ID. :ivar decoded_message: The decoded authorization message (may be JSON). NcCrXrr decoded_message)r r rdrrrrr\z#DecodeAuthorizationMessage.__init__cCr rrr!rrrr%r&z'DecodeAuthorizationMessage.startElementcCr])N requestIdDecodedMessagercr-rrrr/r_z%DecodeAuthorizationMessage.endElementr`rRrrrrrbrarb) r3r7 boto.utilsr: boto.compatrobjectrrIrSrWrbrrrrs q%