baseimage-tutorial-framework/tfw/internals/event_handling/signed_event_handler.py
2019-08-05 13:47:05 +02:00

21 lines
584 B
Python

import logging
from tfw.internals.crypto import KeyManager, verify_message
from .event_handler import EventHandler
LOG = logging.getLogger(__name__)
# pylint: disable=abstract-method
class SignedEventHandler(EventHandler):
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)