public IActionResult TriggerFingerprint() { // Description: Using for DEBUG. URL: https://lifeblocks.site/home/testfingerprintbutton ViewBag.DoctorName = HttpContext.Session.GetString(Globals.currentUserName); // Retrieve the Public IP of the Client Computer using the browser var ip = HttpContext.Connection.RemoteIpAddress; string ipAddress = ip.ToString(); bool debug = true; // true for DEBUG string status = "entered function"; TcpClient tcpClient = new TcpClient(); List <Image> fpList = FingerprintService.authenticateFP("24.84.225.22", 3); // Do fingerprint fetch from windows service here Image fpImg = null; for (int i = 0; i < fpList.Count; i++) { var debugByte = FingerprintService.imgToByte(fpList[i]); fpImg = FingerprintService.byteToImg(debugByte); fpImg.Save(i.ToString() + ".bmp"); } // Write the Public IP of the client computer on the window var model = new TestFingerprintButton() { message = status }; return(RedirectToAction("TestFingerprintButton", model)); }
public IActionResult PatientSignUp(PatientSignUpViewModel patientSignUpViewModel) { // Description: Registers a patient up for a MedNet account ViewBag.DoctorName = HttpContext.Session.GetString(Globals.currentUserName); string signPrivateKey = null, agreePrivateKey = null, signPublicKey = null, agreePublicKey = null; Assets <PatientCredAssetData> userAsset = _bigChainDbService.GetPatientAssetFromID(patientSignUpViewModel.PHN); // Check if PHN is already in use if (userAsset != null) { ModelState.AddModelError("", "A Patient profile with that PHN already exists"); return(View(patientSignUpViewModel)); } // Register fingerprint information int numScans = 5; List <Image> fpList = FingerprintService.authenticateFP("24.84.225.22", numScans); List <byte[]> fpdb = new List <byte[]>(); if (fpList.Count > numScans) { ModelState.AddModelError("", "Something went wrong with the fingerprint scan, try again."); return(View(patientSignUpViewModel)); } // Parse the input data for user registration var passphrase = patientSignUpViewModel.KeyWord; var password = patientSignUpViewModel.Password; // Encrypt fingerprint data List <string> encrList = new List <string>(); foreach (var fp in fpList) { byte[] fpByte = FingerprintService.imgToByte(fp); string encrStr = EncryptionService.encryptFingerprintData(patientSignUpViewModel.PHN, passphrase, fpByte); encrList.Add(encrStr); } // Create a user for the Blockchain EncryptionService.getNewBlockchainUser(out signPrivateKey, out signPublicKey, out agreePrivateKey, out agreePublicKey); // Create the user Asset var userAssetData = new PatientCredAssetData { ID = patientSignUpViewModel.PHN, DateOfBirth = patientSignUpViewModel.DateOfBirth, PrivateKeys = EncryptionService.encryptPrivateKeys(patientSignUpViewModel.PHN, passphrase, signPrivateKey, agreePrivateKey), DateOfRecord = DateTime.Now, SignPublicKey = signPublicKey, AgreePublicKey = agreePublicKey, FingerprintData = encrList, }; // Encrypt the user's password in the metadata var userMetadata = new PatientCredMetadata { FirstName = patientSignUpViewModel.FirstName, LastName = patientSignUpViewModel.LastName, Email = patientSignUpViewModel.Email, hashedPassword = EncryptionService.hashPassword(password) }; // Save the user Asset and Metadata var asset = new AssetSaved <PatientCredAssetData> { Type = AssetType.Patient, Data = userAssetData, RandomId = _random.Next(0, 100000) }; var metadata = new MetaDataSaved <PatientCredMetadata> { data = userMetadata }; // Send the user's information to the Blockchain database _bigChainDbService.SendCreateTransactionToDataBase(asset, metadata, signPrivateKey); return(RedirectToAction("PatientLookUp")); }