Skip to content

Commit

Permalink
Fix up doc references
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Borean <jborean93@gmail.com>
  • Loading branch information
jborean93 committed Aug 9, 2022
1 parent 08e2b09 commit 6b32538
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 81 deletions.
8 changes: 4 additions & 4 deletions gssapi/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Name(rname.Name):
This class may be pickled and unpickled, as well as copied.
The :func:`str` and :func:`bytes` methods may be used to retrieve the
The :class:`str` and :class:`bytes` methods may be used to retrieve the
text of the name.
Note:
Expand Down Expand Up @@ -322,13 +322,13 @@ def mech(self) -> roids.OID:
return self._inquire(mech_name=True).mech

@property
def attributes(self) -> t.Optional["_NameAttributeMapping"]:
def attributes(self) -> t.Optional[MutableMapping]:
"""The attributes of this name (:requires-ext:`rfc6680`)
The attributes are presenting in the form of a
:class:`~collections.MutableMapping` (a dict-like object).
:class:`~collections.abc.MutableMapping` (a dict-like object).
Retrieved values will always be in the form of :class:`frozensets`.
Retrieved values will always be in the form of :class:`frozenset`.
When assigning values, if iterables are used, they be considered to be
the set of values for the given attribute. If a non-iterable is used,
Expand Down
8 changes: 6 additions & 2 deletions gssapi/raw/_enum_extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ def __new__(
else:
classdict[extra_name] = extra_val

return super(ExtendableEnum, metacl).__new__(metacl, name,
bases, classdict)
return super(ExtendableEnum, metacl).__new__(
metacl,
name,
bases,
classdict, # type: ignore[arg-type] # Uses private explicit type
)
2 changes: 1 addition & 1 deletion gssapi/raw/creds.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def add_cred(
and new credential), or to add a new element to an existing credential.
Args:
input_cred (Cred): the set of credentials to which to add the new
input_cred (Creds): the set of credentials to which to add the new
credentials
name (~gssapi.raw.names.Name): name of principal to acquire a
credential for
Expand Down
212 changes: 141 additions & 71 deletions gssapi/raw/named_tuples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,150 +4,220 @@
from gssapi.raw.types import RequirementFlag

if TYPE_CHECKING:
import gssapi.raw as g
import gssapi


class AcquireCredResult(NamedTuple):
"""Credential result when acquiring a GSSAPI credential."""
creds: "g.Creds" #: GSSAPI credentials that were acquired
mechs: Set[OID] #: Set of mechs the cred is for
lifetime: int #: Number of seconds for which the cred will remain valid
#: GSSAPI credentials that were acquired
creds: "gssapi.raw.creds.Creds"
#: Set of mechs the cred is for
mechs: Set[OID]
#: Number of seconds for which the cred will remain valid
lifetime: int


class InquireCredResult(NamedTuple):
"""Information about the credential."""
name: Optional["g.Name"] #: The principal associated with the credential
lifetime: Optional[int] #: Number of seconds which the cred is valid for
usage: Optional[str] #: How the credential can be used
mechs: Optional[Set[OID]] #: Set of mechs the cred is for
#: The principal associated with the credential
name: Optional["gssapi.raw.names.Name"]
#: Number of seconds which the cred is valid for
lifetime: Optional[int]
#: How the credential can be used
usage: Optional[str]
#: Set of mechs the cred is for
mechs: Optional[Set[OID]]


class InquireCredByMechResult(NamedTuple):
"""Information about the credential for a specific mechanism."""
name: Optional["g.Name"] #: The principal associated with the credential
init_lifetime: Optional[int] #: Time valid for initiation, in seconds
accept_lifetime: Optional[int] #: Time valid for accepting, in seconds
usage: Optional[str] #: How the credential can be used
#: The principal associated with the credential
name: Optional["gssapi.raw.names.Name"]
#: Time valid for initiation, in seconds
init_lifetime: Optional[int]
#: Time valid for accepting, in seconds
accept_lifetime: Optional[int]
#: How the credential can be used
usage: Optional[str]


class AddCredResult(NamedTuple):
"""Result of adding to a GSSAPI credential."""
creds: Optional["g.Creds"] #: The credential that was generated
mechs: Set[OID] #: Set of mechs the cred is for
init_lifetime: int #: Time valid for initiation, in seconds
accept_lifetime: int #: Time valid for accepting, in seconds
#: The credential that was generated
creds: Optional["gssapi.raw.creds.Creds"]
#: Set of mechs the cred is for
mechs: Set[OID]
#: Time valid for initiation, in seconds
init_lifetime: int
#: Time valid for accepting, in seconds
accept_lifetime: int


class DisplayNameResult(NamedTuple):
"""Textual representation of a GSSAPI name."""
name: bytes #: The representation of the GSSAPI name
name_type: Optional[OID] #: The type of GSSAPI name
#: The representation of the GSSAPI name
name: bytes
#: The type of GSSAPI name
name_type: Optional[OID]


class WrapResult(NamedTuple):
"""Wrapped message result."""
message: bytes #: The wrapped message
encrypted: bool #: Whether the message is encrypted and not just signed
#: The wrapped message
message: bytes
#: Whether the message is encrypted and not just signed
encrypted: bool


class UnwrapResult(NamedTuple):
"""Unwrapped message result."""
message: bytes #: The unwrapped message
encrypted: bool #: Whether the message was encrypted and not just signed
qop: int #: The quality of protection applied to the message
#: The unwrapped message
message: bytes
#: Whether the message was encrypted and not just signed
encrypted: bool
#: The quality of protection applied to the message
qop: int


class AcceptSecContextResult(NamedTuple):
"""Result when accepting a security context by an initiator."""
context: "g.SecurityContext" #: The acceptor security context
initiator_name: "g.Name" #: The authenticated name of the initiator
mech: OID #: Mechanism with which the context was established
token: Optional[bytes] #: Token to be returned to the initiator
flags: RequirementFlag #: Services requested by the initiator
lifetime: int #: Seconds for which the context is valid for
delegated_creds: Optional["g.Creds"] #: Delegated credentials
more_steps: bool #: More input is required to complete the exchange
#: The acceptor security context
context: "gssapi.raw.sec_contexts.SecurityContext"
#: The authenticated name of the initiator
initiator_name: "gssapi.raw.names.Name"
#: Mechanism with which the context was established
mech: OID
#: Token to be returned to the initiator
token: Optional[bytes]
#: Services requested by the initiator
flags: RequirementFlag
#: Seconds for which the context is valid for
lifetime: int
#: Delegated credentials
delegated_creds: Optional["gssapi.raw.creds.Creds"]
#: More input is required to complete the exchange
more_steps: bool


class InitSecContextResult(NamedTuple):
"""Result when initiating a security context"""
context: "g.SecurityContext" #: The initiator security context
mech: OID #: Mechanism used in the security context
flags: RequirementFlag #: Services available for the context
token: Optional[bytes] #: Token to be sent to the acceptor
lifetime: int #: Seconds for which the context is valid for
more_steps: bool #: More input is required to complete the exchange
#: The initiator security context
context: "gssapi.raw.sec_contexts.SecurityContext"
#: Mechanism used in the security context
mech: OID
#: Services available for the context
flags: RequirementFlag
#: Token to be sent to the acceptor
token: Optional[bytes]
#: Seconds for which the context is valid for
lifetime: int
#: More input is required to complete the exchange
more_steps: bool


class InquireContextResult(NamedTuple):
"""Information about the security context."""
initiator_name: Optional["g.Name"] #: Name of the initiator
target_name: Optional["g.Name"] #: Name of the acceptor
lifetime: Optional[int] #: Time valid for the security context, in seconds
mech: Optional[OID] #: Mech used to create the security context
flags: Optional[RequirementFlag] #: Services available for the context
locally_init: Optional[bool] #: Context was initiated locally
complete: Optional[bool] #: Context has been established and ready to use
#: Name of the initiator
initiator_name: Optional["gssapi.raw.names.Name"]
#: Name of the acceptor
target_name: Optional["gssapi.raw.names.Name"]
#: Time valid for the security context, in seconds
lifetime: Optional[int]
#: Mech used to create the security context
mech: Optional[OID]
#: Services available for the context
flags: Optional[RequirementFlag]
#: Context was initiated locally
locally_init: Optional[bool]
#: Context has been established and ready to use
complete: Optional[bool]


class StoreCredResult(NamedTuple):
"""Result of the credential storing operation."""
mechs: List[OID] #: Mechs that were stored in the credential store
usage: str #: How the credential can be used
#: Mechs that were stored in the credential store
mechs: List[OID]
#: How the credential can be used
usage: str


class IOVUnwrapResult(NamedTuple):
"""Unwrapped IOV message result."""
encrypted: bool #: Whether the message was encrypted and not just signed
qop: int #: The quality of protection applied to the message
#: Whether the message was encrypted and not just signed
encrypted: bool
#: The quality of protection applied to the message
qop: int


class InquireNameResult(NamedTuple):
"""Information about a GSSAPI Name."""
attrs: List[bytes] #: Set of attribute names
is_mech_name: bool #: Name is a mechanism name
mech: OID #: The mechanism if is_name_mech is True
#: Set of attribute names
attrs: List[bytes]
#: Name is a mechanism name
is_mech_name: bool
#: The mechanism if is_name_mech is True
mech: OID


class GetNameAttributeResult(NamedTuple):
"""GSSAPI Name attribute values."""
values: List[bytes] #: Raw values
display_values: List[bytes] #: Human-readable values
authenticated: bool #: Attribute has been authenticated
complete: bool #: Attribute value is marked as complete
#: Raw values
values: List[bytes]
#: Human-readable values
display_values: List[bytes]
#: Attribute has been authenticated
authenticated: bool
#: Attribute value is marked as complete
complete: bool


class InquireAttrsResult(NamedTuple):
"""Set of attributes supported and known by a mechanism."""
mech_attrs: Set[OID] #: The mechanisms attributes
known_mech_attrs: Set[OID] #: Known attributes of the mechanism
#: The mechanisms attributes
mech_attrs: Set[OID]
#: Known attributes of the mechanism
known_mech_attrs: Set[OID]


class DisplayAttrResult(NamedTuple):
"""Information about an attribute."""
name: bytes #: The mechanism name
short_desc: bytes #: Short description of the mechanism
long_desc: bytes #: Long description of the mechanism
#: The mechanism name
name: bytes
#: Short description of the mechanism
short_desc: bytes
#: Long description of the mechanism
long_desc: bytes


class InquireSASLNameResult(NamedTuple):
"""SASL informmation about a GSSAPI Name."""
sasl_mech_name: bytes #: The SASL name
mech_name: bytes #: The mechanism name
mech_description: bytes #: The mechanism description
#: The SASL name
sasl_mech_name: bytes
#: The mechanism name
mech_name: bytes
#: The mechanism description
mech_description: bytes


class Rfc1964KeyData(NamedTuple):
"""Security context key data based on RFC1964."""
sign_alg: int #: Signing algorithm identifier
seal_alg: int #: Sealing algorithm identifier
key_type: int #: Key encryption type identifier
key: bytes #: Encryption key data
#: Signing algorithm identifier
sign_alg: int
#: Sealing algorithm identifier
seal_alg: int
#: Key encryption type identifier
key_type: int
#: Encryption key data
key: bytes


class CfxKeyData(NamedTuple):
"""Securty context key data."""
ctx_key_type: int #: Context key encryption type identifier
ctx_key: bytes #: Context key data - session or sub-session key
acceptor_subkey_type: Optional[int] #: Acceptor key enc type identifier
acceptor_subkey: Optional[bytes] #: Acceptor key data
#: Context key encryption type identifier
ctx_key_type: int
#: Context key data - session or sub-session key
ctx_key: bytes
#: Acceptor key enc type identifier
acceptor_subkey_type: Optional[int]
#: Acceptor key data
acceptor_subkey: Optional[bytes]
4 changes: 2 additions & 2 deletions gssapi/raw/oids.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class OID:
A new OID may be created by passing the `elements` argument
to the constructor. The `elements` argument should be a
`bytes` consisting of the BER-encoded values in the OID.
:class:`bytes` consisting of the BER-encoded values in the OID.
To retrieve the underlying bytes, use the :func:`bytes`
To retrieve the underlying bytes, use the :class:`bytes`
function in Python 3.
This object is hashable, and may be compared using equality
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source-dir=docs/source
build-dir=docs/build
all_files=1
warning-is-error=1
nitpicky=1

[upload_sphinx]
upload-dir = docs/build/html
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ parameterized
Cython
k5test
decorator
mypy
mypy==0.971
types-decorator

0 comments on commit 6b32538

Please sign in to comment.