コード例 #1
0
 /// <summary>
 /// This constructor is used presentation request is scanned
 /// </summary>
 public ProofRequestViewModel(IUserDialogs userDialogs,
                              INavigationService navigationService,
                              IAgentProvider agentContextProvider,
                              IProofService proofService,
                              ILifetimeScope scope,
                              ICredentialService credentialService,
                              IConnectionService connectionService,
                              IEventAggregator eventAggregator,
                              IMessageService messageService,
                              ProofRequest proofRequest,
                              RequestPresentationMessage requestPresentationMessage) : base("Proof Request Detail", userDialogs, navigationService)
 {
     this.userDialogs          = userDialogs;
     this.navigationService    = navigationService;
     this.agentContextProvider = agentContextProvider;
     this.proofService         = proofService;
     this.scope                      = scope;
     this.credentialService          = credentialService;
     this.connectionService          = connectionService;
     this.eventAggregator            = eventAggregator;
     this.messageService             = messageService;
     this.requestPresentationMessage = requestPresentationMessage;
     ConnectionName                  = "Scanned Presentation Request";
     ProofRequest                    = proofRequest;
     ProofRequestName                = ProofRequest?.Name;
     RequestedAttributes             = new ObservableCollection <ProofRequestAttributeViewModel>();
     HasLogo = !string.IsNullOrWhiteSpace(ConnectionLogo);
 }
コード例 #2
0
 public CreateProofRequestResponse
 (
     RequestPresentationMessage aRequestPresentationMessage,
     Guid aCorrelationId
 ) : base(aCorrelationId)
 {
     RequestPresentationMessage = aRequestPresentationMessage;
 }
コード例 #3
0
        private async Task ScanInvite()
        {
            var expectedFormat = ZXing.BarcodeFormat.QR_CODE;

            var opts = new ZXing.Mobile.MobileBarcodeScanningOptions {
                PossibleFormats = new List <ZXing.BarcodeFormat> {
                    expectedFormat
                }
            };

            var context = await _agentContextProvider.GetContextAsync();

            var scanner = new ZXing.Mobile.MobileBarcodeScanner();

            var result = await scanner.Scan(opts);

            if (result == null)
            {
                return;
            }

            AgentMessage message = await MessageDecoder.ParseMessageAsync(result.Text);

            switch (message)
            {
            case ConnectionInvitationMessage invitation:
                break;

            case RequestPresentationMessage presentation:
                RequestPresentationMessage proofRequest = (RequestPresentationMessage)presentation;
                var         service     = message.GetDecorator <ServiceDecorator>(DecoratorNames.ServiceDecorator);
                ProofRecord proofRecord = await _proofService.ProcessRequestAsync(context, proofRequest, null);

                proofRecord.SetTag("RecipientKey", service.RecipientKeys.ToList()[0]);
                proofRecord.SetTag("ServiceEndpoint", service.ServiceEndpoint);
                await _recordService.UpdateAsync(context.Wallet, proofRecord);

                _eventAggregator.Publish(new ApplicationEvent {
                    Type = ApplicationEventType.ProofRequestUpdated
                });
                break;

            default:
                DialogService.Alert("Invalid invitation!");
                return;
            }

            Device.BeginInvokeOnMainThread(async() =>
            {
                if (message is ConnectionInvitationMessage)
                {
                    await NavigationService.NavigateToAsync <AcceptInviteViewModel>(message as ConnectionInvitationMessage, NavigationType.Modal);
                }
            });
        }
コード例 #4
0
        public async Task <AcceptProofRequestResponse> Handle
        (
            AcceptProofRequestRequest aAcceptProofRequestRequest,
            CancellationToken aCancellationToken
        )
        {
            IAgentContext agentContext = await AgentProvider.GetContextAsync();

            RequestPresentationMessage requestPresentationMessage =
                MessageUtils
                .DecodeMessageFromUrlFormat <RequestPresentationMessage>(aAcceptProofRequestRequest.EncodedProofRequestMessage);

            //ProofRecord proofRecord =
            //  await ProofService.
            //  CreatePresentationAsync(agentContext, requestPresentationMessage, requestedCredentials: null);

            //await MessageService.SendAsync(agentContext.Wallet, requestPresentationMessage, proofRecord);
            var response = new AcceptProofRequestResponse(aAcceptProofRequestRequest.CorrelationId);

            return(await Task.Run(() => response));
        }