protected override async void OnStart() { //var installId = await Microsoft.AppCenter.AppCenter.GetInstallIdAsync(); //var id = installId?.ToString(); // Handle when your app starts GlobalStaticFields._getDevice(); Microsoft.AppCenter.AppCenter.Start("ios=c6a76a6d-f8f1-4555-85d1-62a545b651bc;android=026e3b37-e951-4347-8196-ba957754bd5b;uwp=44c96eca-062b-47a3-9626-b4e8524561e5", typeof(Analytics), typeof(Crashes), typeof(Push)); }
private async void LogUserOut() { if (MainPage.Navigation.NavigationStack.Count > 0) { GlobalStaticFields.Customer.IsLoggedOn = false; Current.MainPage = new UnProfiledLoginPage(); // await MainPage.Navigation.PopToRootAsync(); } await GlobalStaticFields._getDevice(); }
public async Task <HttpResponseMessage> Post <T>(T model, string baseUrl, string referenceUrl, string key, byte[] iv, string pageOrViewModel, bool isSensitive = false) { using (var client = new HttpClient()) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; StringContent content; client.BaseAddress = new Uri(baseUrl); client.DefaultRequestHeaders.Add("AppId", URLConstants.AppId); client.DefaultRequestHeaders.Add("SwitchID", GlobalStaticFields.Customer?.Email); client.DefaultRequestHeaders.Add("ChannelID", "1"); var encodedKey = Encoding.UTF8.GetBytes(key); var xkey = Utilities.EncryptData(encodedKey, GlobalStaticFields.Exponent(), GlobalStaticFields.SHaredPublicKey()); var xiv = Convert.ToBase64String(iv); var imei = GlobalStaticFields.DeviceIMEI(); client.DefaultRequestHeaders.Add("X-KEY", xkey); client.DefaultRequestHeaders.Add("X-IV", xiv); client.DefaultRequestHeaders.Add("X-PID", imei); var jObj = string.Empty; if (model != null) { jObj = JsonConvert.SerializeObject(model); } if (isSensitive) { var encryptedData = Security.TripleDESEncrypt(Encoding.UTF8.GetBytes(jObj), encodedKey, iv); dynamic acct = new JObject(); acct.Data = encryptedData; var jdata = JsonConvert.SerializeObject(acct); jObj = jdata; content = new StringContent(jdata, Encoding.UTF8, "application/json"); } else { content = new StringContent(jObj, Encoding.UTF8, "application/json"); } var xcrc = Security.HmacSHA512(jObj, encodedKey); client.DefaultRequestHeaders.Add("X-CRC", xcrc); var request = await client.PostAsync(referenceUrl, content); LogResponse(request, baseUrl, referenceUrl, jObj, pageOrViewModel, isSensitive); return(request); } }
protected override void OnResume() { // Handle when your app resumes GlobalStaticFields.SetSleepTimer(); if (IsTokenExpired()) { MainPage = new AnimationNavigationPage(new UnProfiledLoginPage()); return; } //LogUserOut(); }
private async void DoUpdate() { var position = await GlobalStaticFields.GetLocationFromPlugin().ConfigureAwait(false); if (position != null) { var pos = new Position(position.Latitude, position.Longitude); UserPosition = pos; map.MoveToRegion(MapSpan.FromCenterAndRadius(pos, Distance.FromMeters(100))); GetATMs($"{position.Latitude},{position.Longitude}"); } else { MessageDialog.Show("Find ATM", "Error getting your GPS location at this time.", DialogType.Error, "Retry", UpdateMap, "Cancel", null); } }
private async void ValidateOTP(string otp) { var pd = await ProgressDialog.Show("Validating OTP...please wait!"); var result = await GlobalStaticFields.ValidateOTP(otp).ConfigureAwait(false); if (result) { await pd.Dismiss(); CallIBS(); } else { await pd.Dismiss(); MessageDialog.Show("Invalid OTP", "You have entered an invalid OTP", DialogType.Info, "OK", null); } }
private async void SendOTP() { var pd = await ProgressDialog.Show("Sending OTP to your registered phone number...please wait!"); var result = await GlobalStaticFields.SendOTP().ConfigureAwait(false); if (result) { await pd.Dismiss(); MessageDialog.Show("One Time Password", "OTP has been sent to your Phone and Email", DialogType.Info, "OK", null); } else { await pd.Dismiss(); MessageDialog.Show("One Time Password", "Error sending OTP to your phone number.", DialogType.Info, "Retry", SendOTP, "Cancel", null); } }
public void InitializeAppStart() { GlobalStaticFields.Customer = new Services.Repository.Customer(); Task.Run(async() => await GlobalStaticFields._setLifeStyle()); // Task.Run(() => GlobalStaticFields.GetToken()); Task.Run(GlobalStaticFields.GetLocationFromPlugin); StoreUniqueID(); if (IsTokenExpired()) { //MainPage = new AnimationNavigationPage(new UnProfiledLoginPage()); MainPage = new NavigationPage(new UnProfiledLoginPage()); //MainPage = new NavigationPage(new Pages.BankAccounts.Views.TransactionDetails()); } else { MainPage = new AnimationNavigationPage(new UnProfiledLoginPage()); //MainPage = new NavigationPage(new Dashboard()); // MainPage = new NavigationPage(new Pages.AllTransactions.DetailedTransactionView()); } }
public async Task <HttpResponseMessage> Login(LoginInfo model, string baseUrl, string referenceUrl, string pageOrViewModel, bool isSensitive = false) { using (var client = new HttpClient()) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; var key = Security.GetKey(16); //uniqued key generated dynamically that will be used for symetric encryption var iv = Security.GetKeyByte(8); //initialization vector that will be used for symmetric encrypt.iv and key go together for symmetric encryption var encodedKey = Encoding.UTF8.GetBytes(key); //convert to byte array //Assymetrically encode the key for header transmission var xcrc = Utilities.EncryptData(encodedKey, GlobalStaticFields.Exponent(), GlobalStaticFields.SHaredPublicKey()); //this is the assymmetric encryption, encrypting the symmetric key. //The server will need the private assymetric key to decrypt this in order to get the symetric key //var tripleDes_iv = Security.GetKeyByte(8); //var iv = Convert.ToBase64String(tripleDes_iv); //var key = await Utilities.GetUniqueKey(); client.BaseAddress = new Uri(string.Concat(baseUrl, referenceUrl)); client.DefaultRequestHeaders.Add("AppId", URLConstants.AppId); client.DefaultRequestHeaders.Add("X-KEY", xcrc); client.DefaultRequestHeaders.Add("X-IV", Convert.ToBase64String(iv)); client.DefaultRequestHeaders.Add("X-PID", GlobalStaticFields.DeviceIMEI()); using (var request = new HttpRequestMessage(HttpMethod.Post, client.BaseAddress)) { var encryptedPass = Security.TripleDESEncrypt(Encoding.UTF8.GetBytes(model.Password), Encoding.UTF8.GetBytes(key), iv);//symmetrically encrypting the password using key and IV // var encryptedPass = Convert.ToBase64String(Security.TripleDESEncrypt(Encoding.UTF8.GetBytes(model.Password), Encoding.UTF8.GetBytes(key), tripleDes_iv)); request.Content = new FormUrlEncodedContent(new Dictionary <string, string> { { "grant_type", "password" }, { "username", model.UserID }, { "password", Convert.ToBase64String(encryptedPass) }, }); var response = await client.SendAsync(request); LogResponse(response, baseUrl, referenceUrl, "Sensitive", pageOrViewModel, isSensitive); return(response); } } }
public async Task <HttpResponseMessage> OnBoarding(SwitchUser model, string bearerToken, string baseUrl, string referenceUrl, string pageOrViewModel, bool isSensitive = false) { using (var client = new HttpClient()) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; client.BaseAddress = new Uri(baseUrl); if (!string.IsNullOrEmpty(bearerToken)) { client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", bearerToken); } client.DefaultRequestHeaders.Add("AppId", URLConstants.AppId); client.DefaultRequestHeaders.Add("SwitchID", GlobalStaticFields.Customer?.Email); client.DefaultRequestHeaders.Add("ChannelID", "1"); var key = Security.GetKey(16); var iv = Security.GetKeyByte(8); var encodedKey = Encoding.UTF8.GetBytes(key); var xcrc = Utilities.EncryptData(encodedKey, GlobalStaticFields.Exponent(), GlobalStaticFields.SHaredPublicKey()); client.DefaultRequestHeaders.Add("X-KEY", xcrc); client.DefaultRequestHeaders.Add("X-IV", Convert.ToBase64String(iv)); var jObj = string.Empty; if (model != null) { jObj = JsonConvert.SerializeObject(model); } var encryptedData = Security.TripleDESEncrypt(Encoding.UTF8.GetBytes(jObj), Encoding.UTF8.GetBytes(key), iv); dynamic acct = new JObject(); acct.Data = Convert.ToBase64String(encryptedData); var jdata = JsonConvert.SerializeObject(acct); StringContent content = new StringContent(jdata, Encoding.UTF8, "application/json"); var request = await client.PostAsync(referenceUrl, content); LogResponse(request, baseUrl, referenceUrl, jdata, pageOrViewModel, isSensitive); return(request); } }
protected override void OnCreate(Bundle bundle) { AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironmentUnhandledExceptionRaiser; TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); // CrossCurrentActivity.Current.Init(ApplicationContext); ImageCircleRenderer.Init(); CarouselViewRenderer.Init(); CrossCurrentActivity.Current.Init(this, bundle); // initialize plugin for camera //GlobalStaticFields.ConfigureAppCenter(); // configure appcenter GlobalStaticFields.ConfigureAppCenter(); Xamarin.FormsGoogleMaps.Init(this, bundle); Push.SetSenderId("713211319792"); RegisterCenter(); FFImageLoading.Forms.Platform.CachedImageRenderer.Init(enableFastRenderer: true); FormsControls.Droid.Main.Init(this); FlowListView.Init(); LoadApplication(new App()); HideStatusBar(); }
private async Task LoginButton_Tapped(object sender, System.EventArgs e) { if (BusinessLogic.IsConnectionOK() == true) { Customer.UserID = txtUsername.Text.Trim(); Customer.Password = txtPassword.Text; username = txtUsername.Text.Trim(); pass = txtPassword.Text; string imei = GlobalStaticFields.DeviceIMEI(); // calls same method to get device info var btn = (Button)sender; try { var response = ""; if (BusinessLogic.IsConnectionOK() == true) { try { btn.IsEnabled = false; if (!string.IsNullOrEmpty(Customer.UserID.Trim())) { Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(Customer.UserID.Trim()); if (!match.Success) { MessageDialog.Show("OOPS", "Sorry, The email address you entered is not incorrect. Please verify and try again.", DialogType.Error, "DISMISS", null); return; } } else if (string.IsNullOrEmpty(Customer.UserID)) { MessageDialog.Show("OOPS", "Sorry, Username (Email address) field is required", DialogType.Error, "DISMISS", null); return; } if (string.IsNullOrEmpty(Customer.Password.Trim())) { MessageDialog.Show("OOPS", "Sorry, Password field is required", DialogType.Error, "DISMISS", null); return; } string Username = Customer.UserID; App.Current.Properties["username"] = Username; EnableStatus = false; if (!string.IsNullOrEmpty(Customer.UserID) && !string.IsNullOrEmpty(Customer.Password)) { LoginButton.Text = "Validating Credentials..."; var encPassword = _crypto.Encrypt(Customer.Password); var req = new LoginInfo() { UserID = Customer.UserID, Password = encPassword }; // var loginResponse = await httpService.Post<dynamic>(req, "", URLConstants.SwitchApiBaseUrl, "Switch/Login2", "UnProfiledLoginPage"); var loginResponse = await httpService.Login(req, URLConstants.SwitchNewApiBaseUrl, "Token", "UnProfiledLoginPage"); if (loginResponse.IsSuccessStatusCode) { response = await loginResponse.Content.ReadAsStringAsync(); } if (!string.IsNullOrEmpty(response)) { //Get Token and save token lifespan await LoginHelper.LogUserDetails(response, Username); // get user details in abstract class if (GlobalStaticFields.LoginTest == "Passed") { LoginButton.Text = "Login Success..."; GlobalStaticFields.Customer.IsLoggedOn = true; if (IsRememberPasswordChecked == true) { if (!App.Current.Properties.ContainsKey("email")) { App.Current.Properties["email"] = Username; } } Application.Current.MainPage = new AnimationNavigationPage(new Dashboard.Dashboard()); } else { EnableStatus = true; LoginButton.Text = "Login"; MessageDialog.Show("OOPS", "Sorry, your login attempt failed. Kindly review your credentials and try again.", PopUps.DialogType.Error, "OK", null); return; } } else { var msg = await loginResponse.Content.ReadAsStringAsync(); var jsResponse = JObject.Parse(msg); var err = jsResponse.Value <string>("error"); var errormsg = jsResponse.Value <string>("error_description"); EnableStatus = true; LoginButton.Text = "Login"; if (err == "02" || err == "03") { //option to register device MessageDialog.Show("OOPS", $"{errormsg}{Environment.NewLine} Do you want to register this device?", PopUps.DialogType.Error, "Yes", new Action(() => RegisterDevice(err)), "No", null); } else { MessageDialog.Show("OOPS", errormsg, PopUps.DialogType.Error, "OK", null); } return; } } else { MessageDialog.Show("OOPS", "Username and Pin fields are required", PopUps.DialogType.Error, "OK", null); return; } } catch (Exception ex) { string log = ex.Message; EnableStatus = true; LoginButton.Text = "Login"; await BusinessLogic.Log(ex.ToString(), "Exception on Login Attempt", URLConstants.SwitchApiLiveBaseUrl + "Login2", $"Username: {txtUsername.Text} Password {txtPassword.Text}", response, "UnProfiledLoginPage"); MessageDialog.Show("OOPS", "Sorry, an error occurred, please try again", PopUps.DialogType.Error, "OK", null); } } else { MessageDialog.Show("OOPS", "Sorry, it appears you do not have internet connectivity on your device. Kindly reconnect and try again", DialogType.Error, "DISMISS", null); return; } } catch (Exception ex) { MessageDialog.Show("OOPS", "An error occurred please try again", PopUps.DialogType.Error, "OK", null); } finally { btn.IsEnabled = true; } } }
public async void StoreUniqueID() { await GlobalStaticFields.StoreUniqueID(); }
public void StartApp() { GlobalStaticFields._getDevice(); GlobalStaticFields.getBalanceStatus(); }
async void DoAccountCreation() { string password = _crypto.Encrypt(Pin); try { if (Pin != PinTracker) { MessageDialog.Show("OOPS", "PIN and Confirm PIN Mismatch. Kindly review and try again.", DialogType.Error, "OK", null); return; } else { var key = await Microsoft.AppCenter.AppCenter.GetInstallIdAsync(); DateTime _dob = _vm.DateOfBirth; var model = new SwitchUser() { UserEmail = _vm.Email, Password = password, Gender = _vm.Gender == "Male" ? "M" : "F", DateOfBirth = _dob, FirstName = _vm.Firstname.Trim(), LastName = _vm.Lastname.Trim(), MiddleName = "N/A", Title = _vm.Gender == "Male" ? "Mr" : "Mrs", TPIN = password, PhoneNumber = _vm.WalletPhone, RefferedBy = _vm.ReferralCode, ReferralCode = GlobalStaticFields.RandomString(8), Device = GlobalStaticFields.Device(), IMEI = GlobalStaticFields.DeviceIMEI(), OS = GlobalStaticFields.DeviceOS(), UniqueKey = key?.ToString() ?? Guid.NewGuid().ToString(), AddressLine1 = string.Empty, AddressLine2 = string.Empty, Nationality = 0, AccessLocation = GlobalStaticFields.GetUserLocation, AccountType = "", CustomerTimeZone = DateTime.Now.ToString("yymmddHHmmss"), HomeAddress = "", IsTPIN = false, SignupVerificationCode = "", SecurityQuestionAndAnswers = _qanda //new List<SecurityQuestionViewModel> {_qanda } }; var pd = await ProgressDialog.Show("Sending Request..... Please wait."); var response = await OnBoardingService.DoSwitchAccountCreation(model); if (!string.IsNullOrEmpty(response)) { var dt = JsonConvert.DeserializeObject <NewStatusMessage>(response); if (dt.Status == true) { MessageDialog.Show("SUCCESS", "Account registration was successful.", DialogType.Success, "OK", null); var upgradeModel = new UpgradeAccountForT24() { BVN = GlobalStaticFields.Customer.ListOfAllAccounts.FirstOrDefault(g => g.BVN != null || g.BVN != String.Empty)?.BVN ?? "", CUSNUM = GlobalStaticFields.Customer.ListOfAllAccounts.FirstOrDefault(g => g.CustomerId != null || g.CustomerId != String.Empty)?.CustomerId ?? "", HomeAddress = "", NUBAN = GlobalStaticFields.Customer.ListOfAllAccounts.FirstOrDefault(g => g.nuban != null || g.nuban != string.Empty)?.nuban ?? "", PhoneNumber = _vm.PhoneNumber }; var upgraded = await OnBoardingService.UpgradeAccountForT24(upgradeModel); if (!string.IsNullOrEmpty(upgraded)) { if (upgraded.Contains("true")) { string message = $"Dear Customer You have successfully Onboarded on Switch. kindly ignore this message if it was you, or report to the nearest Sterling bank office if otherwise."; DoLogin(_vm.Email, password); // loguser in and navigate to dashboard. SendMail(message, _vm.Email); // send mail to the specified email address // registration was successful await pd.Dismiss(); } } } else { await pd.Dismiss(); MessageDialog.Show("OOPS", "Sorry, an error occured at our end. Kindly try again later.", DialogType.Error, "OK", null); return; } } else { await pd.Dismiss(); MessageDialog.Show("OOPS", "Sorry, we are unable to create your account at the moment. Kindly try again.", DialogType.Error, "OK", null); return; } } } catch (Exception ex) { string log = ex.Message; } }