public async Task Confirm(string code) { var token = await this.request.Confirm(code); this.state = States.Confirmed; try { this.privateKeyResponse = await this.DownloadPrivateKey(token); } catch (VirgilPrivateServicesException e) when(e.ErrorCode == 40020) { throw new PrivateKeyNotFoundException(); } this.state = States.PrivateKeyDownloaded; if (VirgilKeyPair.IsPrivateKeyEncrypted(this.privateKeyResponse.PrivateKey) && !VirgilKeyPair.CheckPrivateKeyPassword( this.privateKeyResponse.PrivateKey, Encoding.UTF8.GetBytes(this.password)) ) { throw new WrongPrivateKeyPasswordException("Wrong password"); } var card = new PersonalCard(this.recipientCard, new PrivateKey(this.privateKeyResponse.PrivateKey)); this.aggregator.Publish(new CardLoaded(card, this.password)); this.state = States.Finished; }
private async Task <PrivateKeyModel> DownloadPrivateKey(IdentityInfo token) { PrivateKeyModel grabResponse = await ServiceLocator.Services.PrivateKeys.Get(this.recipientCard.Id, token) .ConfigureAwait(false); return(grabResponse); }
public DecryptWithAnotherPasswordOperation( string email, PrivateKeyModel privateKeyResponse, RecipientCard recipientCard, IEventAggregator aggregator) { this.Email = email; this.privateKeyResponse = privateKeyResponse; this.recipientCard = recipientCard; this.aggregator = aggregator; }
/// <summary> /// Create model /// </summary> /// <param name="model"></param> public PrivateKeyApiModel(PrivateKeyModel model) { CurveName = model.CurveName; D = model.D; DP = model.DP; DQ = model.DQ; E = model.E; K = model.K; Kty = model.Kty; N = model.N; P = model.P; Q = model.Q; QI = model.QI; T = model.T; X = model.X; Y = model.Y; }
/// <summary> /// Create model /// </summary> /// <param name="model"></param> public static PrivateKeyApiModel ToApiModel( this PrivateKeyModel model) { if (model == null) { return(null); } return(new PrivateKeyApiModel { CurveName = model.CurveName, D = model.D, DP = model.DP, DQ = model.DQ, E = model.E, K = model.K, Kty = (IIoT.OpcUa.Api.Vault.Models.PrivateKeyType)model.Kty, N = model.N, P = model.P, Q = model.Q, QI = model.QI, T = model.T, X = model.X, Y = model.Y }); }
public async void Get() { PrivateKeyModel privateKey = new PrivateKeyModel() { AuthProviderX509CertUrl = Constants.AuthProviderX509CertUrl, AuthUri = Constants.AuthUri, ClientEmail = Constants.ClientEmail, ClientId = Constants.ClientId, ClientX509CertUrl = Constants.ClientX509CertUrl, PrivateKey = Constants.PrivateKey, PrivateKeyId = Constants.PrivateKeyId, ProjectId = Constants.ProjectId, TokenUri = Constants.TokenUri, Type = Constants.Type }; var privateKeyJson = JsonConvert.SerializeObject(privateKey); if (FirebaseApp.DefaultInstance == null) { FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromJson(privateKeyJson) }); } // Start listing users from the beginning, 1000 at a time. var pagedEnumerable = FirebaseAuth.DefaultInstance.ListUsersAsync(null); var responses = pagedEnumerable.AsRawResponses().GetAsyncEnumerator(); while (await responses.MoveNextAsync()) { ExportedUserRecords response = responses.Current; foreach (ExportedUserRecord user in response.Users) { if (user.CustomClaims.ContainsKey("Role")) { FirebaseUsers.Add( new FirebaseUserModel { UId = user.Uid, DisplayName = user.DisplayName, Email = user.Email, Role = user?.CustomClaims["Role"]?.ToString(), EmailVerified = user.EmailVerified } ); } else { FirebaseUsers.Add( new FirebaseUserModel { UId = user.Uid, DisplayName = user.DisplayName, Email = user.Email, EmailVerified = user.EmailVerified } ); } } } }