from edpauthorization.registry import check_registry_authorized, cleanup_authz_registry
from messageprocessor import MessageProcessorCallback


class AuthorizationCallback(MessageProcessorCallback):
    def input_parsed(self, event_name, request_id, input_obj):
        check_registry_authorized()

    def process_begun(self, event_name, request_id, **kwargs):
        ...

    def business_called(self, event_name, request_id, input_obj, output_obj):
        ...

    def process_finished(self, event_name, request_id, input_obj, output_obj):
        cleanup_authz_registry()

    def parse_exception(self, event_name, request_id, data, exception):
        cleanup_authz_registry()

    def unhandled_exception(self, event_name, request_id, input_obj, exception):
        cleanup_authz_registry()
