Module mydata_did.patched_protocols.present_proof.v1_0.handlers.presentation_proposal_handler
Presentation proposal message handler.
Expand source code
"""Presentation proposal message handler."""
from aries_cloudagent.messaging.base_handler import (
BaseHandler,
BaseResponder,
HandlerException,
RequestContext,
)
from ..manager import PresentationManager
from ..messages.presentation_proposal import PresentationProposal
from aries_cloudagent.utils.tracing import trace_event, get_timer
class PresentationProposalHandler(BaseHandler):
"""Message handler class for presentation proposals."""
async def handle(self, context: RequestContext, responder: BaseResponder):
"""
Message handler logic for presentation proposals.
Args:
context: proposal context
responder: responder callback
"""
r_time = get_timer()
self._logger.debug(
"PresentationProposalHandler called with context %s", context
)
assert isinstance(context.message, PresentationProposal)
self._logger.info(
"Received presentation proposal message: %s",
context.message.serialize(as_string=True),
)
if not context.connection_ready:
raise HandlerException(
"No connection established for presentation proposal"
)
presentation_manager = PresentationManager(context)
presentation_exchange_record = await presentation_manager.receive_proposal()
r_time = trace_event(
context.settings,
context.message,
outcome="PresentationProposalHandler.handle.END",
perf_counter=r_time,
)
# If auto_respond_presentation_proposal is set, reply with proof req
if context.settings.get("debug.auto_respond_presentation_proposal"):
(
presentation_exchange_record,
presentation_request_message,
) = await presentation_manager.create_bound_request(
presentation_exchange_record=presentation_exchange_record,
comment=context.message.comment,
)
await responder.send_reply(presentation_request_message)
trace_event(
context.settings,
presentation_request_message,
outcome="PresentationProposalHandler.handle.PRESENT",
perf_counter=r_time,
)
Classes
class PresentationProposalHandler
-
Message handler class for presentation proposals.
Initialize a BaseHandler instance.
Expand source code
class PresentationProposalHandler(BaseHandler): """Message handler class for presentation proposals.""" async def handle(self, context: RequestContext, responder: BaseResponder): """ Message handler logic for presentation proposals. Args: context: proposal context responder: responder callback """ r_time = get_timer() self._logger.debug( "PresentationProposalHandler called with context %s", context ) assert isinstance(context.message, PresentationProposal) self._logger.info( "Received presentation proposal message: %s", context.message.serialize(as_string=True), ) if not context.connection_ready: raise HandlerException( "No connection established for presentation proposal" ) presentation_manager = PresentationManager(context) presentation_exchange_record = await presentation_manager.receive_proposal() r_time = trace_event( context.settings, context.message, outcome="PresentationProposalHandler.handle.END", perf_counter=r_time, ) # If auto_respond_presentation_proposal is set, reply with proof req if context.settings.get("debug.auto_respond_presentation_proposal"): ( presentation_exchange_record, presentation_request_message, ) = await presentation_manager.create_bound_request( presentation_exchange_record=presentation_exchange_record, comment=context.message.comment, ) await responder.send_reply(presentation_request_message) trace_event( context.settings, presentation_request_message, outcome="PresentationProposalHandler.handle.PRESENT", perf_counter=r_time, )
Ancestors
- aries_cloudagent.messaging.base_handler.BaseHandler
- abc.ABC
Methods
async def handle(self, context: aries_cloudagent.messaging.request_context.RequestContext, responder: aries_cloudagent.messaging.responder.BaseResponder)
-
Message handler logic for presentation proposals.
Args
context
- proposal context
responder
- responder callback
Expand source code
async def handle(self, context: RequestContext, responder: BaseResponder): """ Message handler logic for presentation proposals. Args: context: proposal context responder: responder callback """ r_time = get_timer() self._logger.debug( "PresentationProposalHandler called with context %s", context ) assert isinstance(context.message, PresentationProposal) self._logger.info( "Received presentation proposal message: %s", context.message.serialize(as_string=True), ) if not context.connection_ready: raise HandlerException( "No connection established for presentation proposal" ) presentation_manager = PresentationManager(context) presentation_exchange_record = await presentation_manager.receive_proposal() r_time = trace_event( context.settings, context.message, outcome="PresentationProposalHandler.handle.END", perf_counter=r_time, ) # If auto_respond_presentation_proposal is set, reply with proof req if context.settings.get("debug.auto_respond_presentation_proposal"): ( presentation_exchange_record, presentation_request_message, ) = await presentation_manager.create_bound_request( presentation_exchange_record=presentation_exchange_record, comment=context.message.comment, ) await responder.send_reply(presentation_request_message) trace_event( context.settings, presentation_request_message, outcome="PresentationProposalHandler.handle.PRESENT", perf_counter=r_time, )