j^Xc @s)dZddlmZddlZddlZejeZddlZddl Z ddl m Z ddl m Z mZmZddlmZmZddlmZmZmZmZmZmZmZmZddlmZdd lm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*dd l+m,Z,m-Z-d d d gZ.e/Z0dZ1e2dgZ3e4de5de5de5de1de5Z6dZ7e8e9dZ:e2ddgZ;dZ<d e/fdYZ=de/fdYZ>d e/fdYZ?d e?fdYZ@dS(s-passlib.context - CryptContext implementationi(twith_statementN(twarn(tExpectedStringErrortExpectedTypeErrortPasslibConfigWarning(tget_crypt_handlert_validate_handler_name(thandlerstto_bytest to_unicodet splitcommatas_boolttimertrngt getrandstr(t BASE64_CHARS( t iteritemst num_typestirangetPY2tPY3tunicodetSafeConfigParsertNativeStringIOtBytesIOtunicode_or_bytes_typestnative_string_types(tdeprecated_methodtmemoized_propertyt CryptContexttLazyCryptContextt CryptPolicycCsS|jdr&t|jddSyt|SWntk rNt|SXdS(s>parse vary_rounds string to percent as [0,1) float, or integert%g{Gz?N(tendswithtfloattrstriptintt ValueError(tvalue((s3/usr/lib/python2.7/site-packages/passlib/context.pyt_coerce_vary_rounds)s  tsaltt min_roundst max_roundstdefault_roundst vary_roundst salt_sizecCst|jd|kS(s3detect if handler is registered or a custom handlerN(RtnametNone(thandler((s3/usr/lib/python2.7/site-packages/passlib/context.pyt_is_handler_registeredBscCstS(s dummy function patched into handler.needs_update() by _CryptConfig when hash alg has been deprecated for context. (tTrue(thashtsecret((s3/usr/lib/python2.7/site-packages/passlib/context.pyt_always_needs_updateFsttruncate_errorsaThe CryptPolicy class has been deprecated as of Passlib 1.6, and will be removed in Passlib 1.8. cBseZdZedddZedddZeedZeedZdZ dZ e Z dZd Zd Ze d Zdde d Zdd ZddZddZe e dZe dZddZdddZRS(s .. deprecated:: 1.6 This class has been deprecated, and will be removed in Passlib 1.8. All of its functionality has been rolled into :class:`CryptContext`. This class previously stored the configuration options for the CryptContext class. In the interest of interface simplification, all of this class' functionality has been rolled into the CryptContext class itself. The documentation for this class is now focused on documenting how to migrate to the new api. Additionally, where possible, the deprecation warnings issued by the CryptPolicy methods will list the replacement call that should be used. Constructors ============ CryptPolicy objects can be constructed directly using any of the keywords accepted by :class:`CryptContext`. Direct uses of the :class:`!CryptPolicy` constructor should either pass the keywords directly into the CryptContext constructor, or to :meth:`CryptContext.update` if the policy object was being used to update an existing context object. In addition to passing in keywords directly, CryptPolicy objects can be constructed by the following methods: .. automethod:: from_path .. automethod:: from_string .. automethod:: from_source .. automethod:: from_sources .. automethod:: replace Introspection ============= All of the informational methods provided by this class have been deprecated by identical or similar methods in the :class:`CryptContext` class: .. automethod:: has_schemes .. automethod:: schemes .. automethod:: iter_handlers .. automethod:: get_handler .. automethod:: get_options .. automethod:: handler_is_deprecated .. automethod:: get_min_verify_time Exporting ========= .. automethod:: iter_config .. automethod:: to_dict .. automethod:: to_file .. automethod:: to_string .. note:: CryptPolicy are immutable. Use the :meth:`replace` method to mutate existing instances. .. deprecated:: 1.6 tpasslibsutf-8cCs3ttdtdd|dtj|||S(sWcreate a CryptPolicy instance from a local file. .. deprecated:: 1.6 Creating a new CryptContext from a file, which was previously done via ``CryptContext(policy=CryptPolicy.from_path(path))``, can now be done via ``CryptContext.from_path(path)``. See :meth:`CryptContext.from_path` for details. Updating an existing CryptContext from a file, which was previously done ``context.policy = CryptPolicy.from_path(path)``, can now be done via ``context.load_path(path)``. See :meth:`CryptContext.load_path` for details. sInstead of ``CryptPolicy.from_path(path)``, use ``CryptContext.from_path(path)`` or ``context.load_path(path)`` for an existing CryptContext.t stacklevelit_internal_context(Rt _preambletDeprecationWarningRt from_path(tclstpathtsectiontencoding((s3/usr/lib/python2.7/site-packages/passlib/context.pyR<s  cCs3ttdtdd|dtj|||S(sUcreate a CryptPolicy instance from a string. .. deprecated:: 1.6 Creating a new CryptContext from a string, which was previously done via ``CryptContext(policy=CryptPolicy.from_string(data))``, can now be done via ``CryptContext.from_string(data)``. See :meth:`CryptContext.from_string` for details. Updating an existing CryptContext from a string, which was previously done ``context.policy = CryptPolicy.from_string(data)``, can now be done via ``context.load(data)``. See :meth:`CryptContext.load` for details. sInstead of ``CryptPolicy.from_string(source)``, use ``CryptContext.from_string(source)`` or ``context.load(source)`` for an existing CryptContext.R8iR9(RR:R;Rt from_string(R=tsourceR?R@((s3/usr/lib/python2.7/site-packages/passlib/context.pyRAs  cs|r ttdtddnttr3SttrU|dtStttfst dt fnXt fddDsj d r|dtj S|dtjSd S( screate a CryptPolicy instance from some source. this method autodetects the source type, and invokes the appropriate constructor automatically. it attempts to detect whether the source is a configuration string, a filepath, a dictionary, or an existing CryptPolicy instance. .. deprecated:: 1.6 Create a new CryptContext, which could previously be done via ``CryptContext(policy=CryptPolicy.from_source(source))``, should now be done using an explicit method: the :class:`CryptContext` constructor itself, :meth:`CryptContext.from_path`, or :meth:`CryptContext.from_string`. Updating an existing CryptContext, which could previously be done via ``context.policy = CryptPolicy.from_source(source)``, should now be done using an explicit method: :meth:`CryptContext.update`, or :meth:`CryptContext.load`. sInstead of ``CryptPolicy.from_source()``, use ``CryptContext.from_string(path)`` or ``CryptContext.from_path(source)``, as appropriate.R8iR9sAsource must be CryptPolicy, dict, config string, or file path: %rc3s|]}|kVqdS(N((t.0tc(RB(s3/usr/lib/python2.7/site-packages/passlib/context.pys ss s ./\;:N(RR:R;t isinstanceRtdictRtbytesRt TypeErrorttypetanytstripRAR<(R=RBt_warn((RBs3/usr/lib/python2.7/site-packages/passlib/context.pyt from_sources,cCs|r ttdtddnt|dkrAtdnt|dkrj|j|ddtSi}x9|D]1}|j|j|dtjj dt qwW|d t |S( screate a CryptPolicy instance by merging multiple sources. each source is interpreted as by :meth:`from_source`, and the results are merged together. .. deprecated:: 1.6 Instead of using this method to merge multiple policies together, a :class:`CryptContext` instance should be created, and then the multiple sources merged together via :meth:`CryptContext.load`. swInstead of ``CryptPolicy.from_sources()``, use the various CryptContext constructors followed by ``context.update()``.R8iisno sources specifiediRLtresolveR9( RR:R;tlenR%RMtFalsetupdatet_contexttto_dictR2R(R=tsourcesRLtkwdsRB((s3/usr/lib/python2.7/site-packages/passlib/context.pyt from_sourcess  /cOs|jr#ttdtddnttdtdd|g}|rY|j|n|ro|j|ntj|dtS(screate a new CryptPolicy, optionally updating parts of the existing configuration. .. deprecated:: 1.6 Callers of this method should :meth:`CryptContext.update` or :meth:`CryptContext.copy` instead. sXInstead of ``context.policy.replace()``, use ``context.update()`` or ``context.copy()``.R8iszInstead of ``CryptPolicy().replace()``, create a CryptContext instance and use ``context.update()`` or ``context.copy()``.RL( t _stub_policyRR:R;textendtappendRRVRP(tselftargsRURT((s3/usr/lib/python2.7/site-packages/passlib/context.pytreplaces   cOs|jdd}|rqt|ts-t||_|jdt|_|pT| std||fno|rt|dkrt dn|rt dn|d}nt t dt d d t||_dS( NR9RWsunexpected args: %r %ris%only one positional argument accepteds&cannot specify positional arg and kwdsisInstead of constructing a CryptPolicy instance, create a CryptContext directly, or use ``context.update()`` and ``context.load()`` to reconfigure existing CryptContext instances.R8i( tpopR/RERtAssertionErrorRRRPRWRORHRR:R;(RZR[RUtcontext((s3/usr/lib/python2.7/site-packages/passlib/context.pyt__init__0s  &  cCsM|jr#ttdtddnttdtddt|jjS(sreturn True if policy defines *any* schemes for use. .. deprecated:: 1.6 applications should use ``bool(context.schemes())`` instead. see :meth:`CryptContext.schemes`. sMInstead of ``context.policy.has_schemes()``, use ``bool(context.schemes())``.R8isoInstead of ``CryptPolicy().has_schemes()``, create a CryptContext instance and use ``bool(context.schemes())``.(RWRR:R;tboolRRtschemes(RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyt has_schemesIs  cCsS|jr#ttdtddnttdtdd|jjdtdtS(sreturn iterator over handlers defined in policy. .. deprecated:: 1.6 applications should use ``context.schemes(resolve=True))`` instead. see :meth:`CryptContext.schemes`. sUInstead of ``context.policy.iter_handlers()``, use ``context.schemes(resolve=True)``.R8iswInstead of ``CryptPolicy().iter_handlers()``, create a CryptContext instance and use ``context.schemes(resolve=True)``.RNt unconfigured(RWRR:R;RRRbR2(RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyt iter_handlers]s  cCsY|jr#ttdtddnttdtddt|jjd|dtS(sreturn list of schemes defined in policy. .. deprecated:: 1.6 applications should use :meth:`CryptContext.schemes` instead. sCInstead of ``context.policy.schemes()``, use ``context.schemes()``.R8iseInstead of ``CryptPolicy().schemes()``, create a CryptContext instance and use ``context.schemes()``.RNRd(RWRR:R;tlistRRRbR2(RZRN((s3/usr/lib/python2.7/site-packages/passlib/context.pyRbqs  cCs|jr#ttdtddnttdtddy|jj||dtSWn!tk rz|rsq{dSnXdS(s8return handler as specified by name, or default handler. .. deprecated:: 1.6 applications should use :meth:`CryptContext.handler` instead, though note that the ``required`` keyword has been removed, and the new method will always act as if ``required=True``. sGInstead of ``context.policy.get_handler()``, use ``context.handler()``.R8isiInstead of ``CryptPolicy().get_handler()``, create a CryptContext instance and use ``context.handler()``.RdN( RWRR:R;RRR0R2tKeyErrorR/(RZR.tcategorytrequired((s3/usr/lib/python2.7/site-packages/passlib/context.pyt get_handlers   cCstdtdddS(srget min_verify_time setting for policy. .. deprecated:: 1.6 min_verify_time option will be removed entirely in passlib 1.8 .. versionchanged:: 1.7 this method now always returns the value automatically calculated by :meth:`CryptContext.min_verify_time`, any value specified by policy is ignored. snget_min_verify_time() and min_verify_time option is deprecated and ignored, and will be removed in Passlib 1.8R8ii(RR;(RZRh((s3/usr/lib/python2.7/site-packages/passlib/context.pytget_min_verify_times cCso|jr#ttdtddnttdtddt|drU|j}n|jjj||dS(sLreturn dictionary of options specific to a given handler. .. deprecated:: 1.6 this method has no direct replacement in the 1.6 api, as there is not a clearly defined use-case. however, examining the output of :meth:`CryptContext.to_dict` should serve as the closest alternative. s=``context.policy.get_options()`` will no longer be available.R8is<``CryptPolicy().get_options()`` will no longer be available.R.i( RWRR:R;thasattrR.RRt_configt_get_record_options_with_flag(RZR.Rh((s3/usr/lib/python2.7/site-packages/passlib/context.pyt get_optionss   cCsk|jr#ttdtddnttdtddt|drU|j}n|jj||jS(sBcheck if handler has been deprecated by policy. .. deprecated:: 1.6 this method has no direct replacement in the 1.6 api, as there is not a clearly defined use-case. however, examining the output of :meth:`CryptContext.to_dict` should serve as the closest alternative. sG``context.policy.handler_is_deprecated()`` will no longer be available.R8isF``CryptPolicy().handler_is_deprecated()`` will no longer be available.R.( RWRR:R;RlR.RRR0t deprecated(RZR.Rh((s3/usr/lib/python2.7/site-packages/passlib/context.pythandler_is_deprecateds   cs|jr#ttdtddnttdtdd|j|rjfddt}njdfdjj|DS( siterate over key/value pairs representing the policy object. .. deprecated:: 1.6 applications should use :meth:`CryptContext.to_dict` instead. sOInstead of ``context.policy.iter_config()``, use ``context.to_dict().items()``.R8isqInstead of ``CryptPolicy().iter_config()``, create a CryptContext instance and use ``context.to_dict().items()``.csj|jddS(Nt__t.(t_render_config_keyR\(tkey(R_(s3/usr/lib/python2.7/site-packages/passlib/context.pyt render_keyscSs+t|ttfr'dj|}n|S(Ns, (RERfttupletjoin(R&((s3/usr/lib/python2.7/site-packages/passlib/context.pyt render_valuescSs|S(N((R&((s3/usr/lib/python2.7/site-packages/passlib/context.pytsc3s-|]#\}}||fVqdS(N((RCRuR&(RvRy(s3/usr/lib/python2.7/site-packages/passlib/context.pys s( RWRR:R;RRRPRtRmt iter_config(RZtiniRN((R_RvRys3/usr/lib/python2.7/site-packages/passlib/context.pyR{s        cCsJ|jr#ttdtddnttdtdd|jj|S(sexport policy object as dictionary of options. .. deprecated:: 1.6 applications should use :meth:`CryptContext.to_dict` instead. sCInstead of ``context.policy.to_dict()``, use ``context.to_dict()``.R8iseInstead of ``CryptPolicy().to_dict()``, create a CryptContext instance and use ``context.to_dict()``.(RWRR:R;RRRS(RZRN((s3/usr/lib/python2.7/site-packages/passlib/context.pyRSs  cCsx|jr#ttdtddnttdtdd|jjd|}trg|jd}n|j|dS(sexport policy to file. .. deprecated:: 1.6 applications should use :meth:`CryptContext.to_string` instead, and then write the output to a file as desired. sYInstead of ``context.policy.to_file(stream)``, use ``stream.write(context.to_string())``.R8is{Instead of ``CryptPolicy().to_file(stream)``, create a CryptContext instance and use ``stream.write(context.to_string())``.R?sutf-8N( RWRR:R;RRt to_stringRtencodetwrite(RZtstreamR?tout((s3/usr/lib/python2.7/site-packages/passlib/context.pytto_files  cCsk|jr#ttdtddnttdtdd|jjd|}|rg|j|}n|S(sexport policy to file. .. deprecated:: 1.6 applications should use :meth:`CryptContext.to_string` instead. sGInstead of ``context.policy.to_string()``, use ``context.to_string()``.R8isiInstead of ``CryptPolicy().to_string()``, create a CryptContext instance and use ``context.to_string()``.R?(RWRR:R;RRR}R~(RZR?R@R((s3/usr/lib/python2.7/site-packages/passlib/context.pyR}-s  N(t__name__t __module__t__doc__t classmethodR<RAR2RMRVR\R/RRRPRWR`RcReRbRjRkRoRqR{RSRR}(((s3/usr/lib/python2.7/site-packages/passlib/context.pyRWs09'        $  t _CryptConfigcBs1eZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZidZdZidZd Zed Zd Zd Zd ZdZdZededZdZdZ ddZ!e"dZ#e$dZ%edZ&RS(sparses, validates, and stores CryptContext config this is a helper used internally by CryptContext to handle parsing, validation, and serialization of its config options. split out from the main class, but not made public since that just complicates interface too much (c.f. CryptPolicy) :arg source: config as dict mapping ``(cat,scheme,option) -> value`` cCs;|j|jd|j||j|jdS(NRb(NNsschemes(t_init_scheme_listtgetR/t _init_optionst_init_default_schemest _init_records(RZRB((s3/usr/lib/python2.7/site-packages/passlib/context.pyR`ys  cCsg}g}t|tr*t|}nx|p6dD]}t|drh|}|j}t|n=t|trt|}|j}ntdt|||krt d|fn|j ||j |q7Wt ||_ t ||_ dS(s,initialize .handlers and .schemes attributesR.s+scheme must be name or CryptHandler, not %rs$multiple handlers with same name: %rN((RERR RlR.RRRHRIRgRYRwRRb(RZtdataRRbtelemR0tscheme((s3/usr/lib/python2.7/site-packages/passlib/context.pyRs*      c Cs|j}|j}i|_}i|_}t}xt|D]\\}}} } |j||} | r| r| tkrd}n|rm|| | \} } |dkr| tkrtd| ft n| dkrtdt ny||} Wn)t k r,ii| | 6|6|||dkrt dt n"|dkrtd|fn||fS(NtdefaultR.tstrs"default scheme not found in policyRps str or seqtautois<cannot list other schemes if ``deprecated=['auto']`` is usedsdeprecated elements)deprecated scheme not found in policy: %rRs^'min_verify_time' was deprecated in Passlib 1.6, is ignored in 1.7, and will be removed in 1.8t harden_verifysX'harden_verify' is deprecated & ignored as of Passlib 1.7.1, and will be removed in 1.8Rbs unknown CryptContext keyword: %r(RbRlR.RERRRgR RfRwROR%RR;(RZRRuR&RbR((s3/usr/lib/python2.7/site-packages/passlib/context.pyRs@            cCs|jj||S(sreturn dict mapping category->value for specific context option. .. warning:: treat return value as readonly! (RR(RZRut_default((s3/usr/lib/python2.7/site-packages/passlib/context.pytget_context_optionmap%scCsy|j|}Wntk r+dtfSX|jd}|ry||}Wntk rbqX|dks{||kr|tfSn|tfS(sreturn value of specific option, handling category inheritance. also returns flag indicating whether value is category-specific. N(RRgR/RPRR2(RZRhRuRR&talt((s3/usr/lib/python2.7/site-packages/passlib/context.pytget_context_option_with_flag,s    cCs,y|j||SWntk r'|SXdS(ssreturn all options for (scheme,category) combination .. warning:: treat return value as readonly! N(RRg(RZRRhR((s3/usr/lib/python2.7/site-packages/passlib/context.pyt_get_scheme_optionmapBs cCs|j|jj|S(N(RRbtindex(RZR((s3/usr/lib/python2.7/site-packages/passlib/context.pytget_base_handlerLscCs/|j}d|jkr+|tjj7}n|S(Ntrounds(t setting_kwdstuht HasRoundstusing_rounds_kwds(R0R((s3/usr/lib/python2.7/site-packages/passlib/context.pytexpand_settingsOs c Cs1|j}|ddj}t}|rO|j}|j|d|n|j|j|}x*t|j|D]}|j |q}W|rx-t|j|D]}|j |qWn||d} |j| |r'|j| |j|||||kr't }q'n||fS(sreturn composite dict of all options set for scheme. includes options inherited from 'all' and from default category. result can be modified. returns (kwds, has_cat_specific_options) RN( RR/tcopyRPRQRRRt differenceR]R2( RZRRht get_optionmapRUthas_cat_optionstdefkwdstallowed_settingsRutother((s3/usr/lib/python2.7/site-packages/passlib/context.pytget_scheme_options_with_flagXs(      c Cs_|j}|dj}|_|d}|j}|sAdS|jdpSd}|jd}|sxR|D] }||krr||dZd>Zd>ZedZedddZ edddZ dZ dZ dZ d>eed Zd Zd Zd Zeeed dZedZedddZedddZedZdZed>edZd>eedZd>d>edZdZ edZ!edZ"edZ#edZ$dZ%ddZ&dZ'dZ(d Z)d!Z*d>Z+d"Z,d#Z-d>d>d$Z.d%Z/d>d>d>d&Z0e1d'd(d)d*d+d,d>d>d-Z2e1d'd.d)d*d>d>d/Z3e1d'd.d)d*d>d>d0Z4d>eeed1Z5d>d>d2Z6e1d'd.d)d*d+d3d4Z7d>d>d5Z8d>d>d6Z9d7Z:e;d8Z<d9Z=d"d:Z>d;Z?d>d<Z@d=ZARS(?s-Helper for hashing & verifying passwords using multiple algorithms. Instances of this class allow applications to choose a specific set of hash algorithms which they wish to support, set limits and defaults for the rounds and salt sizes those algorithms should use, flag which algorithms should be deprecated, and automatically handle migrating users to stronger hashes when they log in. Basic usage:: >>> ctx = CryptContext(schemes=[...]) See the Passlib online documentation for details and full documentation. cCsJt|tr||St||r,|S|}|j||SdS(s2internal helper - accepts string, dict, or contextN(RERFtload(R=RBRZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyt _norm_sources   R7sutf-8cCsPt|ts$t|ddn|dt}|j|d|d||S(screate new CryptContext instance from an INI-formatted string. :type source: unicode or bytes :arg source: string containing INI-formatted content. :type section: str :param section: option name of section to read from, defaults to ``"passlib"``. :type encoding: str :arg encoding: optional encoding used when source is bytes, defaults to ``"utf-8"``. :returns: new :class:`CryptContext` instance, configured based on the parameters in the *source* string. Usage example:: >>> from passlib.context import CryptContext >>> context = CryptContext.from_string(''' ... [passlib] ... schemes = sha256_crypt, des_crypt ... sha256_crypt__default_rounds = 30000 ... ''') .. versionadded:: 1.6 .. seealso:: :meth:`to_string`, the inverse of this constructor. sunicode or bytesRBt _autoloadR?R@(RERRRPR(R=RBR?R@RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyRAs !cCs,|dt}|j|d|d||S(screate new CryptContext instance from an INI-formatted file. this functions exactly the same as :meth:`from_string`, except that it loads from a local file. :type path: str :arg path: path to local file containing INI-formatted config. :type section: str :param section: option name of section to read from, defaults to ``"passlib"``. :type encoding: str :arg encoding: encoding used to load file, defaults to ``"utf-8"``. :returns: new CryptContext instance, configured based on the parameters stored in the file *path*. .. versionadded:: 1.6 .. seealso:: :meth:`from_string` for an equivalent usage example. RR?R@(RPt load_path(R=R>R?R@RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyR< scKs<tdt}|j||r8|j|dtn|S(s6Return copy of existing CryptContext instance. This function returns a new CryptContext instance whose configuration is exactly the same as the original, with the exception that any keywords passed in will take precedence over the original settings. As an example:: >>> from passlib.context import CryptContext >>> # given an existing context... >>> ctx1 = CryptContext(["sha256_crypt", "md5_crypt"]) >>> # copy can be used to make a clone, and update >>> # some of the settings at the same time... >>> ctx2 = custom_app_context.copy(default="md5_crypt") >>> # and the original will be unaffected by the change >>> ctx1.default_scheme() "sha256_crypt" >>> ctx2.default_scheme() "md5_crypt" .. versionadded:: 1.6 This method was previously named :meth:`!replace`. That alias has been deprecated, and will be removed in Passlib 1.8. .. seealso:: :meth:`update` RRQ(RRPRR2(RZRUR((s3/usr/lib/python2.7/site-packages/passlib/context.pyR+s  cKs |j|S(sG alias for :meth:`copy`, to match PasswordHash.using() (R(RZRU((s3/usr/lib/python2.7/site-packages/passlib/context.pyRQscKs tdtdd|j|S(s deprecated alias of :meth:`copy`sCryptContext().replace() has been deprecated in Passlib 1.6, and will be removed in Passlib 1.8, it has been renamed to CryptContext().copy()R8i(RR;R(RZRU((s3/usr/lib/python2.7/site-packages/passlib/context.pyR\Ws cKs|dk r||d(tid(RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyt__repr__scCstd|jdtS(NR9RW(RRR2(RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyt _get_policys cCsEtdtddt|tr5|j|jn tddS(NsThe CryptPolicy class and the ``context.policy`` attribute have been deprecated as of Passlib 1.6, and will be removed in Passlib 1.8; please use the ``context.load()`` and ``context.update()`` methods instead.R8isexpected CryptPolicy instance(RR;RERRRRRH(RZR((s3/usr/lib/python2.7/site-packages/passlib/context.pyt _set_policys  tdocsC[deprecated] returns CryptPolicy instance tied to this CryptContextcCsEt}tr"|j||n|j||t|j|S(s<helper read INI from stream, extract passlib section as dict(RRt read_filetreadfpRFtitems(RR?tfilenametp((s3/usr/lib/python2.7/site-packages/passlib/context.pyt_parse_ini_streams  c sfd}trItdd|}||SWdQXnw|dkrztd}||SWdQXnFtd5}|jj|jd}|t|SWdQXdS( sLoad new configuration into CryptContext from a local file. This function is a wrapper for :meth:`load` which loads a configuration string from the local file *path*, instead of an in-memory source. Its behavior and options are otherwise identical to :meth:`!load` when provided with an INI-formatted string. .. versionadded:: 1.6 cs(j|}j|dS(NRQ(RR(RRU(R>R?RZRQ(s3/usr/lib/python2.7/site-packages/passlib/context.pythelperstrtR@Nsutf-8tasciitrb(sutf-8sascii(RtopentreadtdecodeR~R( RZR>RQR?R@RRtfhttmp((R>R?RZRQs3/usr/lib/python2.7/site-packages/passlib/context.pyRs  cst}t|trltr3t||dd}nt|dd|dd}|jt||d}nWt|trt |j j dt}t }n$t |dst|ddn|r|jt fd t|D}n|rG|j d k rG|sd S|}t |j j dt}|j|nt|}||_ |j|j|_|j|_|jr|jjd d n d |_d S( sLoad new configuration into CryptContext, replacing existing config. :arg source: source of new configuration to load. this value can be a number of different types: * a :class:`!dict` object, or compatible Mapping the key/value pairs will be interpreted the same keywords for the :class:`CryptContext` class constructor. * a :class:`!unicode` or :class:`!bytes` string this will be interpreted as an INI-formatted file, and appropriate key/value pairs will be loaded from the specified *section*. * another :class:`!CryptContext` object. this will export a snapshot of its configuration using :meth:`to_dict`. :type update: bool :param update: By default, :meth:`load` will replace the existing configuration entirely. If ``update=True``, it will preserve any existing configuration options that are not overridden by the new source, much like the :meth:`update` method. :type section: str :param section: When parsing an INI-formatted string, :meth:`load` will look for a section named ``"passlib"``. This option allows an alternate section name to be used. Ignored when loading from a dictionary. :type encoding: str :param encoding: Encoding to use when decode bytes from string. Defaults to ``"utf-8"``. Ignoring when loading from a dictionary. :raises TypeError: * If the source cannot be identified. * If an unknown / malformed keyword is encountered. :raises ValueError: If an invalid keyword value is encountered. .. note:: If an error occurs during a :meth:`!load` call, the :class:`!CryptContext` instance will be restored to the configuration it was in before the :meth:`!load` call was made; this is to ensure it is *never* left in an inconsistent state due to a load error. .. versionadded:: 1.6 tparamRBsutf-8tsource_encodings&RNRsstring or dictc3s'|]\}}||fVqdS(N((RCRuR&(tparse(s3/usr/lib/python2.7/site-packages/passlib/context.pys *sNt_strip_unused_context_kwds(R2RERRR RRRRRFRmR{RPRlRt_parse_config_keyRR/RQRt_reset_dummy_verifyRt _get_recordRt_identify_recordRt__dict__R]R(RZRBRQR?R@t parse_keysRtconfig((Rs3/usr/lib/python2.7/site-packages/passlib/context.pyRs><          cCsQt|tst|jddjd}t|}|dkrcd d |d}}}nR|dkrd }|\}}n1|dkr|\}}}ntd|f|dkrd }n&| r|d k rtd |n|d krd }n&| r+|d k r+td |n|sDtd |n|||fS(s>helper used to parse ``cat__scheme__option`` keys into a tupleRsRriiiis)keys must have less than 3 separators: %rRsempty category: %rR_sempty scheme: %rsempty option: %rN(RERR^R\tsplitROR/RH(tckeytpartstcountRRRu((s3/usr/lib/python2.7/site-packages/passlib/context.pyRDs.         cOsv|rVt|dkr'tdn|r<tdn|j|ddtn|rr|j|dtndS(sHelper for quickly changing configuration. This acts much like the :meth:`!dict.update` method: it updates the context's configuration, replacing the original value(s) for the specified keys, and preserving the rest. It accepts any :ref:`keyword ` accepted by the :class:`!CryptContext` constructor. .. versionadded:: 1.6 .. seealso:: :meth:`copy` is(expected at most one positional arguments.positional arg and keywords mutually exclusiveiRQN(RORHRR2(RZR[RU((s3/usr/lib/python2.7/site-packages/passlib/context.pyRQbscs:jj}|r2tfd|DS|SdS(s;return schemes loaded into this CryptContext instance. :type resolve: bool :arg resolve: if ``True``, will return a tuple of :class:`~passlib.ifc.PasswordHash` objects instead of their names. :returns: returns tuple of the schemes configured for this context via the *schemes* option. .. versionadded:: 1.6 This was previously available as ``CryptContext().policy.schemes()`` .. seealso:: the :ref:`schemes ` option for usage example. c3s'|]}j|dVqdS(RdN(R0(RCR(RhRZRd(s3/usr/lib/python2.7/site-packages/passlib/context.pys sN(RmRbRw(RZRNRhRdRb((RhRZRds3/usr/lib/python2.7/site-packages/passlib/context.pyRbs   cCs)|jd|d|}|r"|S|jS(shreturn name of scheme that :meth:`hash` will use by default. :type resolve: bool :arg resolve: if ``True``, will return a :class:`~passlib.ifc.PasswordHash` object instead of the name. :type category: str or None :param category: Optional :ref:`user category `. If specified, this will return the catgory-specific default scheme instead. :returns: name of the default scheme. .. seealso:: the :ref:`default ` option for usage example. .. versionadded:: 1.6 .. versionchanged:: 1.7 This now returns a hasher configured with any CryptContext-specific options (custom rounds settings, etc). Previously this returned the base hasher from :mod:`passlib.hash`. RdN(R0R/R.(RZRhRNRdthasher((s3/usr/lib/python2.7/site-packages/passlib/context.pyRscCsmy'|j||}|r"|jS|SWntk r:nX|jjr]td|fn tddS(shelper to resolve name of scheme -> :class:`~passlib.ifc.PasswordHash` object used by scheme. :arg scheme: This should identify the scheme to lookup. If omitted or set to ``None``, this will return the handler for the default scheme. :arg category: If a user category is specified, and no scheme is provided, it will use the default for that category. Otherwise this parameter is ignored. :param unconfigured: By default, this returns a handler object whose .hash() and .needs_update() methods will honor the configured provided by CryptContext. See ``unconfigured=True`` to get the underlying handler from before any context-specific configuration was applied. :raises KeyError: If the scheme does not exist OR is not being used within this context. :returns: :class:`~passlib.ifc.PasswordHash` object used to implement the named scheme within this context (this will usually be one of the objects from :mod:`passlib.hash`) .. versionadded:: 1.6 This was previously available as ``CryptContext().policy.get_handler()`` .. versionchanged:: 1.7 This now returns a hasher configured with any CryptContext-specific options (custom rounds settings, etc). Previously this returned the base hasher from :mod:`passlib.hash`. s;crypt algorithm not found in this CryptContext instance: %rs8no crypt algorithms loaded in this CryptContext instanceN(R RRgRmR(RZRRhRdR((s3/usr/lib/python2.7/site-packages/passlib/context.pyR0s&  cCstd|jjDS(sCcheck if any handlers in this context aren't in the global registrycss!|]}t|s|VqdS(N(R1(RCR0((s3/usr/lib/python2.7/site-packages/passlib/context.pys -s(RwRmR(RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyt_get_unregistered_handlers+scCs |jjS(s return :class:`!set` containing union of all :ref:`contextual keywords ` supported by the handlers in this context. .. versionadded:: 1.6.6 (RmR(RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyR0scCsH|\}}}|r,d||p$d|fS|r@d||fS|SdS(s*convert 3-part config key to single strings %s__%s__%sR_s%s__%sN((RuRRtoption((s3/usr/lib/python2.7/site-packages/passlib/context.pyRt=s cCst|ttfr'dj|}n_t|trt|trw|ddkrw|rnd|jdnd}qt|}nt|tst d||f|j ddS( s,render value to string suitable for INI files, iR,s%.2ft0sexpected string for key: %r %rR s%%( RERfRwRxRR"R#RRR^R\(RuR&((s3/usr/lib/python2.7/site-packages/passlib/context.pyt_render_ini_valueHs"cs/|jtfd|jj|DS(sgReturn current configuration as a dictionary. :type resolve: bool :arg resolve: if ``True``, the ``schemes`` key will contain a list of a :class:`~passlib.ifc.PasswordHash` objects instead of just their names. This method dumps the current configuration of the CryptContext instance. The key/value pairs should be in the format accepted by the :class:`!CryptContext` class constructor, in fact ``CryptContext(**myctx.to_dict())`` will create an exact copy of ``myctx``. As an example:: >>> # you can dump the configuration of any crypt context... >>> from passlib.apps import ldap_nocrypt_context >>> ldap_nocrypt_context.to_dict() {'schemes': ['ldap_salted_sha1', 'ldap_salted_md5', 'ldap_sha1', 'ldap_md5', 'ldap_plaintext']} .. versionadded:: 1.6 This was previously available as ``CryptContext().policy.to_dict()`` .. seealso:: the :ref:`context-serialization-example` example in the tutorial. c3s'|]\}}||fVqdS(N((RCRuR&(Rv(s3/usr/lib/python2.7/site-packages/passlib/context.pys }s(RtRFRmR{(RZRN((Rvs3/usr/lib/python2.7/site-packages/passlib/context.pyRS]s cCsq|j}|j}|j|xK|jjD]:\}}|||}||}|j|||q/WdS(s(helper to write to ConfigParser instanceN(RtRt add_sectionRmR{R(RZtparserR?RvRytktv((s3/usr/lib/python2.7/site-packages/passlib/context.pyt_write_to_parsers    cCst}|j||t}|j||j}|rh|jddjd|Dn|j}ts|jd}n|S(sHserialize to INI format and return as unicode string. :param section: name of INI section to output, defaults to ``"passlib"``. :returns: CryptContext configuration, serialized to a INI unicode string. This function acts exactly like :meth:`to_dict`, except that it serializes all the contents into a single human-readable string, which can be hand edited, and/or stored in a file. The output of this method is accepted by :meth:`from_string`, :meth:`from_path`, and :meth:`load`. As an example:: >>> # you can dump the configuration of any crypt context... >>> from passlib.apps import ldap_nocrypt_context >>> print ldap_nocrypt_context.to_string() [passlib] schemes = ldap_salted_sha1, ldap_salted_md5, ldap_sha1, ldap_md5, ldap_plaintext .. versionadded:: 1.6 This was previously available as ``CryptContext().policy.to_string()`` .. seealso:: the :ref:`context-serialization-example` example in the tutorial. s# NOTE: the %s handler(s) are not registered with Passlib, # this string may not correctly reproduce the current configuration. s, css|]}t|jVqdS(N(treprR.(RCR0((s3/usr/lib/python2.7/site-packages/passlib/context.pys ssutf-8( RRRRRRxtgetvalueRR(RZR?Rtbuft unregisteredR((s3/usr/lib/python2.7/site-packages/passlib/context.pyR}s     ii ig{Gz?icCs|jdS(N(R(RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pytreset_min_verify_timescCsK|r7t|ts't|dn|j||S|j||SdS(sCreturn record based on scheme, or failing that, by identifying hashR3N(RERRR R (RZR3RRh((s3/usr/lib/python2.7/site-packages/passlib/context.pyt_get_or_identify_records cCsG|s dS|jjj|j}x|D]}|j|dq)WdS(sf helper which removes any context keywords from **kwds** that are known to be used by another scheme in this context, but are NOT supported by handler specified by **record**. .. note:: as optimization, load() will set this method to None on a per-instance basis if there are no context kwds. N(RmRRR]R/(RZRURt unused_kwdsRu((s3/usr/lib/python2.7/site-packages/passlib/context.pyRs  cCsM|dk rtdtn|j|||}|jpL|j|d|S(s Check if hash needs to be replaced for some reason, in which case the secret should be re-hashed. This function is the core of CryptContext's support for hash migration: This function takes in a hash string, and checks the scheme, number of rounds, and other properties against the current policy. It returns ``True`` if the hash is using a deprecated scheme, or is otherwise outside of the bounds specified by the policy (e.g. the number of rounds is lower than :ref:`min_rounds ` configuration for that algorithm). If so, the password should be re-hashed using :meth:`hash` Otherwise, it will return ``False``. :type hash: unicode or bytes :arg hash: The hash string to examine. :type scheme: str or None :param scheme: Optional scheme to use. Scheme must be one of the ones configured for this context (see the :ref:`schemes ` option). If no scheme is specified, it will be identified based on the value of *hash*. .. deprecated:: 1.7 Support for this keyword is deprecated, and will be removed in Passlib 2.0. :type category: str or None :param category: Optional :ref:`user category `. If specified, this will cause any category-specific defaults to be used when determining if the hash needs to be updated (e.g. is below the minimum rounds). :type secret: unicode, bytes, or None :param secret: Optional secret associated with the provided ``hash``. This is not required, or even currently used for anything... it's for forward-compatibility with any future update checks that might need this information. If provided, Passlib assumes the secret has already been verified successfully against the hash. .. versionadded:: 1.6 :returns: ``True`` if hash should be replaced, otherwise ``False``. :raises ValueError: If the hash did not match any of the configured :meth:`schemes`. .. versionadded:: 1.6 This method was previously named :meth:`hash_needs_update`. .. seealso:: the :ref:`context-migration-example` example in the tutorial. sqCryptContext.needs_update(): 'scheme' keyword is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0R4N(R/RR;R!Rpt needs_update(RZR3RRhR4R((s3/usr/lib/python2.7/site-packages/passlib/context.pyR#s ;  Rps1.6tremoveds2.0t replacementsCryptContext.needs_update()cCs|j|||S(sLegacy alias for :meth:`needs_update`. .. deprecated:: 1.6 This method was renamed to :meth:`!needs_update` in version 1.6. This alias will be removed in version 2.0, and should only be used for compatibility with Passlib 1.3 - 1.5. (R#(RZR3RRh((s3/usr/lib/python2.7/site-packages/passlib/context.pythash_needs_updateAs s1.7cKs>|j||}|j}|r1|||n|j|S(sGenerate a config string for specified scheme. .. deprecated:: 1.7 This method will be removed in version 2.0, and should only be used for compatibility with Passlib 1.3 - 1.6. (R Rt genconfig(RZRRhRRt strip_unused((s3/usr/lib/python2.7/site-packages/passlib/context.pyR'Ls  cKsG|j|||}|j}|r4|||n|j|||S(sGenerate hash for the specified secret using another hash. .. deprecated:: 1.7 This method will be removed in version 2.0, and should only be used for compatibility with Passlib 1.3 - 1.6. (R!Rtgenhash(RZR4R RRhRURR(((s3/usr/lib/python2.7/site-packages/passlib/context.pyR)[s  cCsJ|j|||}|dkr%dS|r?|r8|jS|Sn|jSdS(sAttempt to identify which algorithm the hash belongs to. Note that this will only consider the algorithms currently configured for this context (see the :ref:`schemes ` option). All registered algorithms will be checked, from first to last, and whichever one positively identifies the hash first will be returned. :type hash: unicode or bytes :arg hash: The hash string to test. :type category: str or None :param category: Optional :ref:`user category `. Ignored by this function, this parameter is provided for symmetry with the other methods. :type resolve: bool :param resolve: If ``True``, returns the hash handler itself, instead of the name of the hash. :type required: bool :param required: If ``True``, this will raise a ValueError if the hash cannot be identified, instead of returning ``None``. :returns: The handler which first identifies the hash, or ``None`` if none of the algorithms identify the hash. N(R R/RR.(RZR3RhRNRiRdR((s3/usr/lib/python2.7/site-packages/passlib/context.pyRjs" cKs]|dk rtdtn|j||}|j}|rM|||n|j||S(sZrun secret through selected algorithm, returning resulting hash. :type secret: unicode or bytes :arg secret: the password to hash. :type scheme: str or None :param scheme: Optional scheme to use. Scheme must be one of the ones configured for this context (see the :ref:`schemes ` option). If no scheme is specified, the configured default will be used. .. deprecated:: 1.7 Support for this keyword is deprecated, and will be removed in Passlib 2.0. :type category: str or None :param category: Optional :ref:`user category `. If specified, this will cause any category-specific defaults to be used when hashing the password (e.g. different default scheme, different default rounds values, etc). :param \*\*kwds: All other keyword options are passed to the selected algorithm's :meth:`PasswordHash.hash() ` method. :returns: The secret as encoded by the specified algorithm and options. The return value will always be a :class:`!str`. :raises TypeError, ValueError: * If any of the arguments have an invalid type or value. This includes any keywords passed to the underlying hash's :meth:`PasswordHash.hash() ` method. .. seealso:: the :ref:`context-basic-example` example in the tutorial siCryptContext.hash(): 'scheme' keyword is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0N(R/RR;R RR3(RZR4RRhRURR(((s3/usr/lib/python2.7/site-packages/passlib/context.pyR3s+   sCryptContext.hash()cOs|j||S(s Legacy alias for :meth:`hash`. .. deprecated:: 1.7 This method was renamed to :meth:`!hash` in version 1.7. This alias will be removed in version 2.0, and should only be used for compatibility with Passlib 1.3 - 1.6. (R3(RZR[RU((s3/usr/lib/python2.7/site-packages/passlib/context.pytencrypts cKs}|dk rtdtn|dkr6|jtS|j|||}|j}|rj|||n|j|||S(sverify secret against an existing hash. If no scheme is specified, this will attempt to identify the scheme based on the contents of the provided hash (limited to the schemes configured for this context). It will then check whether the password verifies against the hash. :type secret: unicode or bytes :arg secret: the secret to verify :type hash: unicode or bytes :arg hash: hash string to compare to if ``None`` is passed in, this will be treated as "never verifying" :type scheme: str :param scheme: Optionally force context to use specific scheme. This is usually not needed, as most hashes can be unambiguously identified. Scheme must be one of the ones configured for this context (see the :ref:`schemes ` option). .. deprecated:: 1.7 Support for this keyword is deprecated, and will be removed in Passlib 2.0. :type category: str or None :param category: Optional :ref:`user category ` string. This is mainly used when generating new hashes, it has little effect when verifying; this keyword is mainly provided for symmetry. :param \*\*kwds: All additional keywords are passed to the appropriate handler, and should match its :attr:`~passlib.ifc.PasswordHash.context_kwds`. :returns: ``True`` if the password matched the hash, else ``False``. :raises ValueError: * if the hash did not match any of the configured :meth:`schemes`. * if any of the arguments have an invalid value (this includes any keywords passed to the underlying hash's :meth:`PasswordHash.verify() ` method). :raises TypeError: * if any of the arguments have an invalid type (this includes any keywords passed to the underlying hash's :meth:`PasswordHash.verify() ` method). .. seealso:: the :ref:`context-basic-example` example in the tutorial skCryptContext.verify(): 'scheme' keyword is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0N(R/RR;t dummy_verifyRPR!Rtverify(RZR4R3RRhRURR(((s3/usr/lib/python2.7/site-packages/passlib/context.pyR,s;     c Ks|dk rtdtn|dkr<|jtdfS|j|||}|j}|r|r|j}|||n|}|j|||stdfS|j s|j |d|rt |j |d||fSt dfSdS(s verify password and re-hash the password if needed, all in a single call. This is a convenience method which takes care of all the following: first it verifies the password (:meth:`~CryptContext.verify`), if this is successfull it checks if the hash needs updating (:meth:`~CryptContext.needs_update`), and if so, re-hashes the password (:meth:`~CryptContext.hash`), returning the replacement hash. This series of steps is a very common task for applications which wish to update deprecated hashes, and this call takes care of all 3 steps efficiently. :type secret: unicode or bytes :arg secret: the secret to verify :type secret: unicode or bytes :arg hash: hash string to compare to. if ``None`` is passed in, this will be treated as "never verifying" :type scheme: str :param scheme: Optionally force context to use specific scheme. This is usually not needed, as most hashes can be unambiguously identified. Scheme must be one of the ones configured for this context (see the :ref:`schemes ` option). .. deprecated:: 1.7 Support for this keyword is deprecated, and will be removed in Passlib 2.0. :type category: str or None :param category: Optional :ref:`user category `. If specified, this will cause any category-specific defaults to be used if the password has to be re-hashed. :param \*\*kwds: all additional keywords are passed to the appropriate handler, and should match that hash's :attr:`PasswordHash.context_kwds `. :returns: This function returns a tuple containing two elements: ``(verified, replacement_hash)``. The first is a boolean flag indicating whether the password verified, and the second an optional replacement hash. The tuple will always match one of the following 3 cases: * ``(False, None)`` indicates the secret failed to verify. * ``(True, None)`` indicates the secret verified correctly, and the hash does not need updating. * ``(True, str)`` indicates the secret verified correctly, but the current hash needs to be updated. The :class:`!str` will be the freshly generated hash, to replace the old one. :raises TypeError, ValueError: For the same reasons as :meth:`verify`. .. seealso:: the :ref:`context-migration-example` example in the tutorial. skCryptContext.verify(): 'scheme' keyword is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0R4RhN( R/RR;R+RPR!RRR,RpR#R2R3( RZR4R3RRhRURR(t clean_kwds((s3/usr/lib/python2.7/site-packages/passlib/context.pytverify_and_update( s"@         stoo many secretscCs|j|jS(s> precalculated hash for dummy_verify() to use (R3t _dummy_secret(RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyt _dummy_hash scCst|jj|dS(s> flush memoized values used by dummy_verify() N(RIR0t clear_cache(RZ((s3/usr/lib/python2.7/site-packages/passlib/context.pyR scCs|j|j|jtS(s Helper that applications can call when user wasn't found, in order to simulate time it would take to hash a password. Runs verify() against a dummy hash, to simulate verification of a real account password. :param elapsed: .. deprecated:: 1.7.1 this option is ignored, and will be removed in passlib 1.8. .. versionadded:: 1.7 (R,R/R0RP(RZtelapsed((s3/usr/lib/python2.7/site-packages/passlib/context.pyR+ scCs|j|dj S(sn test if hash represents a usuable password -- i.e. does not represent an unusuable password such as ``"!"``, which is recognized by the :class:`~passlib.hash.unix_disabled` hash. :raises ValueError: if the hash is not recognized (typically solved by adding ``unix_disabled`` to the list of schemes). N(R R/R(RZR3((s3/usr/lib/python2.7/site-packages/passlib/context.pyt is_enabled s cCs(|jj}|jst|j|S(s return a string to disable logins for user, usually by returning a non-verifying string such as ``"!"``. :param hash: Callers can optionally provide the account's existing hash. Some disabled handlers (such as :class:`!unix_disabled`) will encode this into the returned value, so that it can be recovered via :meth:`enable`. :raises RuntimeError: if this function is called w/o a disabled hasher (such as :class:`~passlib.hash.unix_disabled`) included in the list of schemes. :returns: hash string which will be recognized as valid by the context, but is guaranteed to not validate against *any* password. (RmRRR^tdisable(RZR3R((s3/usr/lib/python2.7/site-packages/passlib/context.pyR4 s cCs0|j|d}|jr(|j|S|SdS(s inverse of :meth:`disable` -- attempts to recover original hash which was converted by a :meth:`!disable` call into a disabled hash -- thus restoring the user's original password. :raises ValueError: if original hash not present, or if the disabled handler doesn't support encoding the original hash (e.g. ``django_disabled``) :returns: the original hash. N(R R/Rtenable(RZR3R((s3/usr/lib/python2.7/site-packages/passlib/context.pyR5 s  N(BRRRR/RmR R RRRAR<RRR\RR2R`RRRtpropertyRRRRPRRRRQRbRR0RRRtRRSRR}tmvt_estimate_max_samplestmvt_estimate_min_samplestmvt_estimate_max_timetmvt_estimate_resolutionRRR R!RR#RR&R'R)RR3R*R,R.R/RR0RR+R3R4R5(((s3/usr/lib/python2.7/site-packages/passlib/context.pyRs & &      o E15    # =  E   ,8$ Ma   cBs2eZdZdZddZdZdZRS(sCryptContext subclass which doesn't load handlers until needed. This is a subclass of CryptContext which takes in a set of arguments exactly like CryptContext, but won't import any handlers (or even parse its arguments) until the first time one of its methods is accessed. :arg schemes: The first positional argument can be a list of schemes, or omitted, just like CryptContext. :param onload: If a callable is passed in via this keyword, it will be invoked at lazy-load time with the following signature: ``onload(**kwds) -> kwds``; where ``kwds`` is all the additional kwds passed to LazyCryptContext. It should perform any additional deferred initialization, and return the final dict of options to be passed to CryptContext. .. versionadded:: 1.6 :param create_policy: .. deprecated:: 1.6 This option will be removed in Passlib 1.8, applications should use ``onload`` instead. :param kwds: All additional keywords are passed to CryptContext; or to the *onload* function (if provided). This is mainly used internally by modules such as :mod:`passlib.apps`, which define a large number of contexts, but only a few of them will be needed at any one time. Use of this class saves the memory needed to import the specified handlers until the context instance is actually accessed. As well, it allows constructing a context at *module-init* time, but using :func:`!onload()` to provide dynamic configuration at *application-run* time. .. note:: This class is only useful if you're referencing handler objects by name, and don't want them imported until runtime. If you want to have the config validated before your application runs, or are passing in already-imported handler instances, you should use :class:`CryptContext` instead. .. versionadded:: 1.4 cKs&|dk r||dsT    :L     gC