Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Removed DOB
  • Loading branch information
yhyakuna authored Nov 29, 2018
1 parent 59f19dd commit f90afe4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
22 changes: 7 additions & 15 deletions encryption/vault-transit-rewrap/DBHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public static async Task CreateTablesAsync()
"`state` VARCHAR(256) NOT NULL," +
"`postcode` VARCHAR(256) NOT NULL," +
"`email` VARCHAR(256) NOT NULL," +
"`dob` VARCHAR(256) NULL," +
"PRIMARY KEY (user_id) " +
") engine=InnoDB;";
cmd.CommandText = command;
Expand All @@ -47,7 +46,6 @@ public static async Task CreateDBAsync()
string command = "CREATE DATABASE IF NOT EXISTS my_app";
cmd.CommandText = command;


await cmd.ExecuteNonQueryAsync();
Console.WriteLine("Created (if not exist) my_app DB");
}
Expand All @@ -64,15 +62,14 @@ public static async Task InsertRecordAsyc(Record r)

string command = "INSERT INTO `user_data` " +
"(`user_name`, `first_name`, `last_name`, `address`, " +
"`city`, `state`, `postcode`, `email`, `dob`) " +
"`city`, `state`, `postcode`, `email`) " +
$"VALUES (\"{r.Login.Username}\", \"{r.Name.First}\", \"{r.Name.Last}\", " +
$"\"{r.Location.Street}\", \"{r.Location.City}\", \"{r.Location.State}\", " +
$"\"{r.Location.Postcode}\", \"{r.Email}\", \"{r.DOB}\");";
$"\"{r.Location.Postcode}\", \"{r.Email}\");";

cmd.CommandText = command;

var rowsAffected = await cmd.ExecuteNonQueryAsync();
//Console.WriteLine($"Created {rowsAffected} rows");
}
}
}
Expand All @@ -85,14 +82,13 @@ public static async Task UpdateRecordAsyc(Record r)
await db.Connection.OpenAsync();
using (var cmd = db.Connection.CreateCommand())
{

string command = "UPDATE `user_data` " +
$"SET `address` = \"{r.Location.Street}\", " +
$"`dob` = \"{r.DOB}\", " +
$"`email` = \"{r.Email}\" " +
$"WHERE `user_id` = {r.Id.Value}";

cmd.CommandText = command;
Console.WriteLine("Command: " + command);

await cmd.ExecuteNonQueryAsync();
}
Expand All @@ -110,13 +106,11 @@ public static async Task<List<Record>> FindRecordsToRewrap(int keyVersion)
using (var cmd = db.Connection.CreateCommand())
{
int count = 0;
string command = "SELECT `user_id`, `email`,`dob`, `address` " +
string command = "SELECT `user_id`, `email`, `address` " +
"FROM `user_data` " +
$"WHERE `dob` NOT LIKE \"vault:v{keyVersion}:%\" " +
$"OR `email` NOT LIKE \"vault:v{keyVersion}:%\" " +
$"WHERE `email` NOT LIKE \"vault:v{keyVersion}:%\" " +
$"OR `address` NOT LIKE \"vault:v{keyVersion}:%\" ";



cmd.CommandText = command;

var reader = await cmd.ExecuteReaderAsync();
Expand All @@ -126,8 +120,7 @@ public static async Task<List<Record>> FindRecordsToRewrap(int keyVersion)
count++;
var user_id = reader.GetInt32(0);
var email = reader.GetString(1);
var dob = reader.GetString(2);
var address = reader.GetString(3);
var address = reader.GetString(2);

RewrapExample.Location addr = new Location();
addr.Street = address;
Expand All @@ -137,7 +130,6 @@ public static async Task<List<Record>> FindRecordsToRewrap(int keyVersion)
Record r = new Record
{
Id = id,
DOB = dob,
Email = email,
Location = addr,
};
Expand Down
1 change: 0 additions & 1 deletion encryption/vault-transit-rewrap/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static async Task SeedDB(string numRecords)
var tasks = new List<Task>();
foreach (var record in apiResults.Records) {
ICollection<Task> encryptValues = new List<Task>();
record.DOB = await client.EncryptValue(record.DOB);
record.Location.Street = await client.EncryptValue(record.Location.Street);
record.Email = await client.EncryptValue(record.Email);
tasks.Add(DBHelper.InsertRecordAsyc(record));
Expand Down
2 changes: 0 additions & 2 deletions encryption/vault-transit-rewrap/Record.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public class Record
public Location Location { get; set; }
public string Email { get; set; }
public Login Login { get; set; }
public string DOB { get; set; }
public string Registered { get; set; }
public string Phone { get; set; }
public string Cell { get; set; }
public Id Id { get; set; }
Expand Down
1 change: 0 additions & 1 deletion encryption/vault-transit-rewrap/VaultClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public async Task ReWrapRecords(ICollection<Record> users)
{
count++;
user.Location.Street = await ReWrapValue(user.Location.Street);
user.DOB = await ReWrapValue(user.DOB);
user.Email = await ReWrapValue(user.Email);

tasks.Add(DBHelper.UpdateRecordAsyc(user));
Expand Down

0 comments on commit f90afe4

Please sign in to comment.