Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (IsLoginUser)
            {
                //链接为模拟用户页面
                lbtnLogin.Visible = true;
            }

            string localName = HttpContext.Current.User.Identity.Name.ToLower();
            lblUserInfo.Text = localName;

            string to = new SwitchUser().IsExist(fromUserCode);
            if (!string.IsNullOrEmpty(to))
            {
                lblUserInfo.Text      = "founder\\" + to;
                lblUserInfo.ForeColor = Color.Red;
                lbtnLogout.Visible    = true;
            }

            to = new LoginUser().IsExist(fromUserCode);
            if (!string.IsNullOrEmpty(to))
            {
                lblUserInfo.Text      = localName + "模拟了" + to;
                lblUserInfo.ForeColor = Color.Red;
            }
            //映射用户
            if (IsMappingUser)
            {
                Pkurg.PWorldBPM.Business.Sys.SYS_MappingUser model = ClassMappingUser.GetState(localName);
                if (model == null)
                {
                    lbtnMapping.Visible       = false;
                    lbtnCancelMapping.Visible = false;
                }
                else if (model.State == 0)
                {
                    lbtnMapping.Visible       = true;
                    lbtnCancelMapping.Visible = false;
                }
                else if (model.State == 1)
                {
                    lblUserInfo.Text          = localName + "映射了" + model.ToUserCode;
                    lblUserInfo.ForeColor     = Color.Red;
                    lbtnMapping.Visible       = false;
                    lbtnCancelMapping.Visible = true;
                }
            }
        }
    }
        public static async Task <string> DoSwitchAccountCreation(SwitchUser customerCreation)
        {
            string responseData = string.Empty;

            try
            {
                _apiService = new ApiRequest();
                var response = await _apiService.OnBoarding(customerCreation, "", URLConstants.switchAPINewBaseURL, "Switch/CompleteSignUp", "OnboardingAccountPINCreation");

                if (response.IsSuccessStatusCode)
                {
                    responseData = await response.Content.ReadAsStringAsync();
                }
            }
            catch (Exception ex)
            {
                string log = ex.Message;
            }
            return(responseData);
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        protected override void Run()
        {
            Console.Clear();

            Console.WriteLine("Welcome to EncodedOS. Type help to show avaiable commands!");

            while (Variables.shutdown == false)
            {
                Console.Write(Environment.NewLine + Variables.curDir + "> ");
                string cmd = Console.ReadLine();

                switch (cmd)
                {
                case "help":
                {
                    Console.WriteLine(Variables.commands);
                    break;
                }

                case "list user":
                {
                    if (File.Exists(Variables.usersFile) == true)
                    {
                        string[] userLines = File.ReadAllLines(Variables.usersFile);         //TODO: Change File.ReadAllLines with Filesystem.ReadAllLines
                        for (int i = 0; i < userLines.Length; i++)
                        {
                            Console.WriteLine("> " + userLines[i].Split('=')[0].ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("> The users.txt file wasn't found! The filesystem must be new created!");
                        Filesystem.CreateFileSystem();
                        Console.WriteLine("> Filesystem was created. Restarting OS now....");
                        for (int i = 0; i < 700000; i++)
                        {
                            ;
                        }
                        Sys.Power.Reboot();
                    }
                    break;
                }

                case "list groups":
                {
                    if (File.Exists(Variables.groupsFile) == true)
                    {
                        string[] groupLines = File.ReadAllLines(Variables.groupsFile);         //TODO: Change File.ReadAllLines with Filesystem.ReadAllLines
                        for (int i = 0; i < groupLines.Length; i++)
                        {
                            if (groupLines[i].ToString().Contains("=") == true)
                            {
                                Console.WriteLine("> " + groupLines[i].ToString().Split('=')[0].Split(':')[0]);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("> The groups.txt file wasn't found! The filesystem must be new created!");
                        Filesystem.CreateFileSystem();
                        Console.WriteLine("> Filesystem was created. Restarting OS now....");
                        for (int i = 0; i < 700000; i++)
                        {
                            ;
                        }
                        Sys.Power.Reboot();
                    }
                    break;
                }

                case "reboot":
                {
                    Sys.Power.Reboot();
                    break;
                }

                case "format":
                {
                    Format.SetToBegin();
                    break;
                }

                case "shutdown":
                {
                    Variables.shutdown = true;
                    break;
                }

                case "whoami":
                {
                    Console.WriteLine("> " + Variables.curUser.userName);
                    break;
                }

                case "cls":
                {
                    Console.Clear();
                    break;
                }

                case "clear":
                {
                    Console.Clear();
                    break;
                }

                case "ls":
                {
                    string[] filesInDir = Directory.GetFiles(Variables.rootDir);
                    string[] dirsInDir  = Directory.GetDirectories(Variables.rootDir);

                    Console.WriteLine("Listing for Folder: " + Variables.curDir);

                    for (int i = 0; i < filesInDir.Length; i++)
                    {
                        Console.WriteLine("<File> " + filesInDir[i].ToString());
                    }

                    for (int i = 0; i < dirsInDir.Length; i++)
                    {
                        Console.WriteLine("<Folder> " + dirsInDir[i].ToString());
                    }

                    break;
                }

                case "dir":
                {
                    string[] filesInDir = Directory.GetFiles(Variables.curDir);
                    string[] dirsInDir  = Directory.GetDirectories(Variables.curDir);

                    Console.WriteLine("Listing for Folder: " + Variables.curDir);

                    for (int i = 0; i < filesInDir.Length; i++)
                    {
                        Console.WriteLine("<File> " + filesInDir[i].ToString());
                    }

                    for (int i = 0; i < dirsInDir.Length; i++)
                    {
                        Console.WriteLine("<Folder> " + dirsInDir[i].ToString());
                    }

                    break;
                }

                default:
                {
                    if (cmd.Contains("mkfile"))         //Create File TODO: Check if Path contains rootDir
                    {
                        if (cmd.Contains(" "))
                        {
                            string filename = cmd.Split(new string[] { " " }, StringSplitOptions.None)[1];
                            Filesystem.CreateFile(filename);
                        }
                        else
                        {
                            Console.WriteLine("> You need to specific a filename!");
                        }
                    }
                    else if (cmd.Contains("rm"))         //Delete File TODO: Check whether the fileToDelete is a full path or in the current directory
                    {
                        if (cmd.Contains(" "))
                        {
                            string fileToDelete = cmd.Split(new string[] { " " }, StringSplitOptions.None)[1];

                            if (Variables.curDir == Variables.rootDir)
                            {
                                Filesystem.DeleteFile(Variables.rootDir + fileToDelete);
                            }
                            else
                            {
                                Filesystem.DeleteFile(Variables.curDir + @"\" + fileToDelete);
                            }
                        }
                        else
                        {
                            Console.WriteLine("You need to specific a filename!");
                        }
                    }
                    else if (cmd.Contains("cd"))         //Change Directory
                    {
                        if (cmd.Contains(" "))
                        {
                            string dirToSwitchTo = cmd.Split(new string[] { " " }, StringSplitOptions.None)[1];         //Userinput

                            if (dirToSwitchTo.Contains(Variables.rootDir))
                            {
                                Variables.curDir = dirToSwitchTo;
                            }
                            else if (dirToSwitchTo == "..")
                            {
                                if (Variables.curDir.Substring(0, Variables.curDir.LastIndexOf('\\')) == "0:")
                                {
                                    Variables.curDir = Variables.rootDir;
                                }
                                else
                                {
                                    Variables.curDir = Variables.curDir.Substring(0, Variables.curDir.LastIndexOf('\\'));
                                }
                            }
                            else
                            {
                                if (Variables.curDir == Variables.rootDir)
                                {
                                    string[] dirsInCurDir = Directory.GetDirectories(Variables.curDir);
                                    for (int i = 0; i < dirsInCurDir.Length; i++)
                                    {
                                        if (dirsInCurDir[i].ToString() == dirToSwitchTo || dirsInCurDir[i].ToString().ToLower() == dirToSwitchTo || dirsInCurDir[i].ToString().ToUpper() == dirToSwitchTo)         //Use this to get the correct Directory name
                                        {
                                            Variables.curDir += dirsInCurDir[i].ToString();
                                        }
                                    }
                                }
                                else
                                {
                                    string[] dirsInCurDir = Directory.GetDirectories(Variables.curDir);
                                    for (int i = 0; i < dirsInCurDir.Length; i++)
                                    {
                                        if (dirsInCurDir[i].ToString() == dirToSwitchTo || dirsInCurDir[i].ToString().ToLower() == dirToSwitchTo || dirsInCurDir[i].ToString().ToUpper() == dirToSwitchTo)         //Use this to get the correct Directory name
                                        {
                                            Variables.curDir += @"\" + dirsInCurDir[i].ToString();
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("> You must enter a folder to change to!");
                        }
                    }
                    else if (cmd.Contains("su"))         //Switch User
                    {
                        if (cmd.Contains(" "))
                        {
                            string userToSwitchTo = cmd.Split(new string[] { " " }, StringSplitOptions.None)[1];
                            SwitchUser.su(userToSwitchTo);
                        }
                        else
                        {
                            Console.WriteLine("> You must enter a user to switch to!");
                        }
                    }
                    else
                    {
                        Console.WriteLine("> Unrecognized command: " + cmd + Environment.NewLine + "> Type help to get a list of avaiable commands!");
                    }
                    break;
                }
                }
            }
            return;
        }
        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;
            }
        }
Пример #6
0
    /// <summary>
    /// 根据登录名获取用户实体
    /// 有缓存
    /// by yanghechun
    /// </summary>
    /// <returns></returns>
    public UserInfo GetEmployee()
    {
        string local = "";

        //移动端没有用户认证,匿名认证
        if (!HttpContext.Current.User.Identity.IsAuthenticated)
        {
            //app.ashx,移动端查看的view页面请求都会有这两个参数。
            //PC端获取不到当前用户,因为没有userencode
            if (!string.IsNullOrEmpty(HttpContext.Current.Request["userencode"]) && HttpContext.Current.Request["ref"].ToLower() == "mobile")
            {
                local = DESEncrypt.Decrypt(HttpContext.Current.Request["userencode"]);
            }
            else
            {
                local = "zybpm";
            }
        }
        else
        {
            local = HttpContext.Current.User.Identity.Name.ToLower().Replace("founder\\", "");
        }

        string loginName = local;

        //处理方正世纪的域账号
        if (local.ToLower().StartsWith("hold") && local.ToLower() == "hold\\wangwh")
        {
            loginName = "wangweihong";
        }
        else
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                //切换用户
                string to = new SwitchUser().IsExist(local);
                if (!string.IsNullOrEmpty(to))
                {
                    loginName = to;
                }
                //模拟用户
                to = new LoginUser().IsExist(local);
                if (!string.IsNullOrEmpty(to))
                {
                    loginName = to;
                }
                //映射用户
                if (IsMappingUser(local))
                {
                    Pkurg.PWorldBPM.Business.Sys.MappingUser ClassMappingUser = new Pkurg.PWorldBPM.Business.Sys.MappingUser();
                    to = ClassMappingUser.GetToUserCode(local, 1);
                    if (!string.IsNullOrEmpty(to))
                    {
                        loginName = to;
                    }
                }
            }
        }

        //最终用户
        string key = "cache_user_" + loginName;

        if (Pkurg.PWorldBPM.Common.Cache.DataCache.GetCache(key) == null)
        {
            Pkurg.PWorldBPM.Common.Services.OrgService services = new Pkurg.PWorldBPM.Common.Services.OrgService();
            UserInfo model = services.GetUserInfo(loginName);
            if (model != null)
            {
                Pkurg.PWorldBPM.Common.Cache.DataCache.SetCache(key, model, DateTime.Now.AddDays(7), TimeSpan.Zero);
            }
            else
            {
                //被模拟的用户不存在,重新切换到当前用户
                bool flag1 = new SwitchUser().DeleteByTo(loginName);
                bool flag2 = new LoginUser().DeleteByTo(loginName);
                if (flag1 & flag2)
                {
                    HttpContext.Current.Response.Redirect("~/Default.aspx");
                }
                else
                {
                    throw new Exception("未找到用户信息");
                }
            }
        }
        return((UserInfo)Pkurg.PWorldBPM.Common.Cache.DataCache.GetCache(key));
    }