// Issue a credential to an active connection.
        private async Task <JObject> IssueCredential(string connectionId, int enrolleeId)
        {
            var enrollee = _context.Enrollees
                           .SingleOrDefault(e => e.Id == enrolleeId);

            var credential = GetCredentialByConnectionIdAsync(connectionId);

            if (credential == null || credential.AcceptedCredentialDate != null)
            {
                return(null);
            }

            var credentialAttributes = await CreateCredentialAttributesAsync(enrolleeId);

            var credentialOffer = await CreateCredentialOfferAsync(connectionId, credentialAttributes);

            var issueCredentialResponse = await _verifiableCredentialClient.IssueCredentialAsync(credentialOffer);

            // Set credentials CredentialExchangeId from issue credential response
            credential.CredentialExchangeId = (string)issueCredentialResponse.SelectToken("credential_exchange_id");
            _context.Credentials.Update(credential);

            await _context.SaveChangesAsync();

            return(issueCredentialResponse);
        }
Пример #2
0
        // Issue a credential to an active connection.
        private async Task <JObject> IssueCredential(string connectionId, int enrolleeId)
        {
            var enrollee = _context.Enrollees
                           .SingleOrDefault(e => e.Id == enrolleeId);

            var credential = GetCredentialByIdAsync((int)enrollee.CredentialId);

            if (credential.AcceptedCredentialDate != null)
            {
                return(null);
            }

            var credentialAttributes = await CreateCredentialAttributesAsync(enrolleeId);

            var credentialOffer = await CreateCredentialOfferAsync(connectionId, credentialAttributes);

            return(await _verifiableCredentialClient.IssueCredentialAsync(credentialOffer));
        }
Пример #3
0
        // Issue a credential to an active connection.
        private async Task <JObject> IssueCredential(Credential credential, string connectionId, Guid guid)
        {
            if (credential == null || credential.AcceptedCredentialDate != null)
            {
                _logger.LogInformation("Cannot issue credential, credential from database is null, or a credential has already been accepted.");
                return(null);
            }

            var credentialAttributes = await CreateCredentialAttributesAsync(credential.Connection.PatientId, guid);

            var credentialOffer = await CreateCredentialOfferAsync(connectionId, credentialAttributes);

            var issueCredentialResponse = await _verifiableCredentialClient.IssueCredentialAsync(credentialOffer);

            // // Set credentials CredentialExchangeId from issue credential response
            credential.CredentialExchangeId = (string)issueCredentialResponse.SelectToken("credential_exchange_id");
            _context.Credentials.Update(credential);

            await _context.SaveChangesAsync();

            return(issueCredentialResponse);
        }