codekingpro/portable-devtools
114k
1"""Credential Store Extension"""2import typing as t3 4if t.TYPE_CHECKING:5 from gssapi.raw.creds import Creds6 from gssapi.raw.named_tuples import AcquireCredResult, StoreCredResult7 from gssapi.raw.names import Name8 from gssapi.raw.oids import OID9 10 11def acquire_cred_from(12 dict_store: t.Optional[13 t.Dict[t.Union[bytes, str], t.Union[bytes, str]]14 ] = None,15 name: t.Optional["Name"] = None,16 lifetime: t.Optional[int] = None,17 mechs: t.Optional[t.Iterable["OID"]] = None,18 usage: str = 'both',19) -> "AcquireCredResult":20 """Acquire credentials from the given store.21 22 This method acquires credentials from the store specified by the23 given credential store information.24 25 The credential store information is a dictionary containing26 mechanisms-specific keys and values pointing to a credential store27 or stores.28 29 Args:30 store (dict): the credential store information pointing to the31 credential store from which to acquire the credentials.32 See :doc:`credstore` for valid values33 name (~gssapi.raw.names.Name): the name associated with the34 credentials, or None for the default name35 lifetime (int): the desired lifetime of the credentials in seconds, or36 None for indefinite37 mechs (list): the desired mechanisms to be used with these38 credentials, or None for the default set39 usage (str): the usage for these credentials -- either 'both',40 'initiate', or 'accept'41 42 Returns:43 AcquireCredResult: the acquired credentials and information about44 them45 46 Raises:47 ~gssapi.exceptions.GSSError48 """49 50 51def add_cred_from(52 dict_store: t.Optional[53 t.Dict[t.Union[bytes, str], t.Union[bytes, str]]54 ],55 input_creds: "Creds",56 name: "Name",57 mech: "OID",58 usage: str = 'both',59 init_lifetime: t.Optional[int] = None,60 accept_lifetime: t.Optional[int] = None,61) -> "AcquireCredResult":62 """Acquire credentials to add to the current set from the given store.63 64 This method works like :func:`acquire_cred_from`, except that it65 adds the acquired credentials for a single mechanism to a copy of66 the current set, instead of creating a new set for multiple mechanisms.67 Unlike :func:`~gssapi.raw.creds.acquire_cred`, you cannot pass None for the68 desired name or mechanism.69 70 The credential store information is a dictionary containing71 mechanisms-specific keys and values pointing to a credential store72 or stores.73 74 Args:75 store (dict): the store into which to store the credentials,76 or None for the default store.77 See :doc:`credstore` for valid values78 name (~gssapi.raw.names.Name): the name associated with the credentials79 mech (~gssapi.OID): the desired mechanism to be used with these80 credentials81 usage (str): the usage for these credentials -- either 'both',82 'initiate', or 'accept'83 init_lifetime (int): the desired initiate lifetime of the credentials84 in seconds, or None for indefinite85 accept_lifetime (int): the desired accept lifetime of the credentials86 in seconds, or None for indefinite87 88 Returns:89 AcquireCredResult: the new credentials set and information about90 it91 92 Raises:93 ~gssapi.exceptions.GSSError94 """95 96 97def store_cred_into(98 dict_store: t.Optional[99 t.Dict[t.Union[bytes, str], t.Union[bytes, str]]100 ],101 creds: "Creds",102 usage: str = 'both',103 mech: t.Optional["OID"] = None,104 overwrite: bool = False,105 set_default: bool = False,106) -> "StoreCredResult":107 """Store credentials into the given store.108 109 This method stores the given credentials into the store specified110 by the given store information. They may then be retrieved later using111 :func:`acquire_cred_from` or :func:`add_cred_from`.112 113 The credential store information is a dictionary containing114 mechanisms-specific keys and values pointing to a credential store115 or stores.116 117 Args:118 store (dict): the store into which to store the credentials,119 or None for the default store.120 See :doc:`credstore` for valid values121 creds (Creds): the credentials to store122 usage (str): the usage to store the credentials with -- either123 'both', 'initiate', or 'accept'124 mech (~gssapi.OID): the mechansim to associate with the stored125 credentials126 overwrite (bool): whether or not to overwrite existing credentials127 stored with the same name, etc128 set_default (bool): whether or not to set these credentials as129 the default credentials for the given store.130 131 Returns:132 StoreCredResult: the results of the credential storing operation133 134 Raises:135 ~gssapi.exceptions.GSSError136 """137 