plugin XEP-0373 and XEP-0374: Implementation of OX and OXIM:
GPGME is used as the GPG provider. rel 374
This commit is contained in:
parent
f160577a65
commit
6d1e942f43
1 changed files with 2710 additions and 34 deletions
|
|
@ -22,8 +22,10 @@ import enum
|
|||
import secrets
|
||||
import string
|
||||
from typing import Dict, NamedTuple, Optional, Set, Tuple, cast
|
||||
from typing_extensions import Final
|
||||
|
||||
from lxml import etree
|
||||
from sat.core import exceptions
|
||||
|
||||
from sat.core.constants import Const as C
|
||||
from sat.core.i18n import D_
|
||||
|
|
@ -68,7 +70,7 @@ PLUGIN_INFO = {
|
|||
}
|
||||
|
||||
|
||||
NS_SCE = "urn:xmpp:sce:1"
|
||||
NS_SCE: Final = "urn:xmpp:sce:1"
|
||||
|
||||
|
||||
class ProfileRequirementsNotMet(Exception):
|
||||
|
|
@ -114,7 +116,8 @@ class SCECustomAffix(ABC):
|
|||
remain. Do not modify.
|
||||
@return: An affix element to include in the envelope. The element must have the
|
||||
name :attr:`element_name` and must validate using :attr:`element_schema`.
|
||||
@raise ValueError: if the affix couldn't be built.
|
||||
@raise ValueError: if the affix couldn't be built due to missing information on
|
||||
the stanza.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
|
|
@ -384,7 +387,7 @@ class XEP_0420: # pylint: disable=invalid-name
|
|||
by the decryption scheme utilizing SCE.
|
||||
@return: The parsed and processed values of all affixes that were present on the
|
||||
envelope, notably including the timestamp.
|
||||
@raise ValueError: if the serialized envelope element is malformed.
|
||||
@raise exceptions.ParsingError: if the serialized envelope element is malformed.
|
||||
@raise ProfileRequirementsNotMet: if one or more affixes required by the profile
|
||||
are missing from the envelope.
|
||||
@raise AffixVerificationFailed: if an affix included in the envelope fails to
|
||||
|
|
@ -399,7 +402,9 @@ class XEP_0420: # pylint: disable=invalid-name
|
|||
try:
|
||||
envelope_serialized_string = envelope_serialized.decode("utf-8")
|
||||
except UnicodeError as e:
|
||||
raise ValueError("Serialized envelope can't bare parsed as utf-8.") from e
|
||||
raise exceptions.ParsingError(
|
||||
"Serialized envelope can't bare parsed as utf-8."
|
||||
) from e
|
||||
|
||||
custom_affixes = set(profile.custom_policies.keys())
|
||||
|
||||
|
|
@ -420,7 +425,9 @@ class XEP_0420: # pylint: disable=invalid-name
|
|||
try:
|
||||
etree.fromstring(envelope_serialized_string, parser)
|
||||
except etree.XMLSyntaxError as e:
|
||||
raise ValueError("Serialized envelope doesn't pass schema validation.") from e
|
||||
raise exceptions.ParsingError(
|
||||
"Serialized envelope doesn't pass schema validation."
|
||||
) from e
|
||||
|
||||
# Prepare the envelope and content elements
|
||||
envelope = cast(domish.Element, ElementParser()(envelope_serialized_string))
|
||||
|
|
@ -452,7 +459,7 @@ class XEP_0420: # pylint: disable=invalid-name
|
|||
timestamp_value = None if time_element is None else \
|
||||
XEP_0082.parse_datetime(time_element["stamp"])
|
||||
except ValueError as e:
|
||||
raise AffixVerificationFailed("Malformed time affix") from e
|
||||
raise AffixVerificationFailed("Malformed time affix.") from e
|
||||
|
||||
# The to affix is verified by comparing the to attribute of the stanza with the
|
||||
# JID referenced by the affix. Note that only bare JIDs are compared as per the
|
||||
|
|
|
|||
Loading…
Reference in a new issue