/// <summary> /// Revokes a global <see cref="VirgilCard"/> from Virgil Security services. /// </summary> /// <param name="card">The Card to be revoked.</param> /// <param name="key">The Key associated with the revoking Card.</param> /// <param name="identityToken">The identity token.</param> public async Task RevokeGlobalAsync(VirgilCard card, VirgilKey key, IdentityValidationToken identityToken) { var revokeRequest = new RevokeGlobalCardRequest(card.Id, RevocationReason.Unspecified, identityToken.Value); var fingerprint = this.context.Crypto.CalculateFingerprint(revokeRequest.Snapshot); var signature = key.Sign(fingerprint.GetValue()); revokeRequest.AppendSignature(card.Id, signature.GetBytes()); await this.context.Client.RevokeGlobalCardAsync(revokeRequest); }
/// <summary> /// Publishes a current <see cref="VirgilCard"/> to the Virgil Security services into global scope. /// </summary> /// <example> /// <code> /// // generate a Virgil Key /// var aliceKey = virgil.Keys.Generate(); /// /// // save the Virgil Key into storage /// aliceKey.Save("[KEY_NAME]", "[KEY_PASSWORD]"); /// /// // create a Global Virgil Card /// var aliceCard = virgil.Cards.CreateGlobal( /// identity: "*****@*****.**", /// identityType: IdentityType.Email, /// ownerKey: aliceKey /// ); /// // initiate identity verification process /// var attempt = await aliceCard.CheckIdentityAsync(); /// /// // confirm an identity and grab the validation token /// var token = await attempt.ConfirmAsync(new EmailConfirmation("[CONFIRMATION_CODE]")); /// /// // publish the Virgil Card /// await aliceCard.PublishAsGlobalAsync(token); /// </code> /// </example> internal async Task PublishAsGlobalAsync(IdentityValidationToken identityToken) { if (identityToken == null) { throw new ArgumentNullException(nameof(identityToken)); } if (this.card.SnapshotModel.Scope != CardScope.Global) { throw new NotSupportedException(); } var publishCardRequest = new PublishGlobalCardRequest(this.card.Snapshot, identityToken.Value, this.card.Meta.Signatures); var updatedModel = await this.context.Client .PublishGlobalCardAsync(publishCardRequest).ConfigureAwait(false); this.card.Meta = updatedModel.Meta; }
/// <summary> /// Publishes a <see cref="VirgilCard"/> into global Virgil Services scope. /// </summary> /// <param name="card">The Card to be published.</param> /// <param name="token">The identity validation token.</param> public Task PublishGlobalAsync(VirgilCard card, IdentityValidationToken token) { return(card.PublishAsGlobalAsync(token)); }