baseimage-tutorial-framework/tfw/internals/event_handling/signed_event_handler.py

21 lines
606 B
Python

import logging
from tfw.internals.crypto import KeyManager, verify_message
from .control_event_handler import ControlEventHandler
LOG = logging.getLogger(__name__)
# pylint: disable=abstract-method
class SignedEventHandler(ControlEventHandler):
def __init__(self, connector):
self._auth_key = KeyManager().auth_key
super().__init__(connector)
def _event_callback(self, message):
if verify_message(self._auth_key, message):
self.handle_event(message, self.connector)
else:
LOG.error('Message does not have valid signature: %s', message)