public List <User> Users()
        {
            List <User> users = new List <User>();

            string query = " select * from " + wt;

            using (SqlCommand command = new SqlCommand(query, connection))
            {
                if (connection.State != ConnectionState.Open)
                {
                    try
                    {
                        connection.Open();
                    }
                    catch (SqlException E) { Debug.WriteLine(E.Message); }
                }
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        User u = new User();
                        u.id       = Convert.ToInt16(reader["id"].ToString());
                        u.Name     = reader["userName"].ToString();
                        u.password = reader["PassHash"].ToString();
                        u.password = StringCipher.Decrypt(u.password, u.Name);
                        int a = Convert.ToInt16(reader["IsAdmin"].ToString());
                        Func <int, bool> Isadmin = x => x == 1;
                        u.IsAdmin = Isadmin(a);
                        users.Add(u);
                    }
                }
            }
            return(users);
        }
Esempio n. 2
0
        public static List <TicketStatus> GetTicketStatus(string Code, string ConnectionString)
        {
            TicketFacade        tac       = new TicketFacade(StringCipher.Decrypt(Helper.GetMasterConnctionstring(), General.passPhrase));
            List <TicketStatus> lstStatus = new List <TicketStatus>();

            lstStatus = tac.GetAttributeTypeForTicketForClients(Code).ToList(); // MP-846 Admin database cleanup and code cleanup.-CLIENT
            if (Code == "101")                                                  //101 = PRIORITY_STATUS
            {
                lstStatus = lstStatus.OrderByDescending(x => x.Code).ToList();
            }
            else if (Code == "102") //101 = TICKET_STATUS
            {
                if (System.Web.HttpContext.Current.Request.Url.AbsolutePath.IndexOf("edit") < 0)
                {
                    lstStatus = lstStatus.Where(x => x.Code == "102001").ToList(); //102001=Created
                }
                else
                {
                    lstStatus = lstStatus.Where(x => x.Code == "102001" || x.Code == "102005").ToList(); //102001=Created, 102005=Closed
                }
            }
            else if (Code == "103" && System.Web.HttpContext.Current.Request.Url.AbsolutePath.IndexOf("edit") < 0)//103 = TICKET SOURCE
            {
                lstStatus = lstStatus.Where(x => x.Value == "Web Application").ToList();
            }
            return(lstStatus);
        }
        //public ActionResult ChangePassword(int id)
        //{
        //    var user = _userManager.GetUserInformationByUserId(id);
        //    user.Password = StringCipher.Decrypt(user.Password, "salam_cse_10_R");
        //    return View(user);
        //}

        //------------------ Change password------------------------
        public PartialViewResult ChangePassword(int id)
        {
            var user = _userManager.GetUserInformationByUserId(id);

            user.Password = StringCipher.Decrypt(user.Password, "salam_cse_10_R");
            return(PartialView("_ChangePasswordPartialPage", user));
        }
Esempio n. 4
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtUserName.Text))
            {
                MessageBox.Show("Please enter a user name.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string password  = txtPassword.Text;
                string plaintext = password;

                // Encrypt the password
                string encryptedstring = StringCipher.Encrypt(plaintext, password);
                //Console.WriteLine(encryptedstring);

                // Decrypt the password
                string decryptedstring = StringCipher.Decrypt(encryptedstring, password);
                //Console.WriteLine(decryptedstring);

                // Find userNamer in file
                //string result = XmlUtils.XmlSearch.searchXMLFileOriginal("..\\..\\Data\\", "Users.usr", "John");
                string result = XmlUtils.XmlSearch.searchXMLFileOriginal("..\\..\\Data\\", "booksort.xml", "admin");
                // Console.WriteLine("returned value: " + result);

                this.Hide();
                var selectTest = new SelectTest();
                selectTest.Closed += (s, args) => this.Close();
                selectTest.Show();
            }
        }
Esempio n. 5
0
        public ActionResult Create(TicketEntity model)
        {
            ModelState.Remove("AssignedTo");
            if (ModelState.IsValid)
            {
                if (model != null)
                {
                    if (!string.IsNullOrEmpty(SessionHelper.ImageName))
                    {
                        model.Files = SessionHelper.ImageName.TrimEnd(':');
                    }

                    model.EnteredBy = Helper.UserName;
                    TicketFacade tac = new TicketFacade(StringCipher.Decrypt(Helper.GetMasterConnctionstring(), General.passPhrase));
                    //Save Ticket
                    int ticketId = tac.InsertUpdateTicketForClient(model);  // MP-846 Admin database cleanup and code cleanup.-CLIENT

                    if (ticketId > 0)
                    {
                        #region Send Notification on success
                        // When Create new ticket at time send mail user for creation of ticket.
                        TicketEntity objTicket = new TicketEntity();
                        objTicket = tac.GetTicketByIDByClients(ticketId);  // MP-846 Admin database cleanup and code cleanup.-CLIENT
                        string SupportEmail = ConfigurationManager.AppSettings["ApplicationEmail"];
                        string emailBody    = string.Empty;
                        if (Helper.Branding == Branding.Matchbook.ToString())
                        {
                            emailBody += "Hi, " + model.EnteredBy + "<br/><br/>";
                            emailBody += MessageCollection.MatchbookTicketText + "<br/><br/>";
                            emailBody += "<table width='100%'>";
                            emailBody += "<tr><td style='width:11%;'>Title :</td><td>" + model.Title + "</td></tr>";
                            emailBody += "<tr><td style='width:11%;'>Priority :</td><td>" + objTicket.PriorityValue + "</td></tr>";
                            emailBody += "<tr><td style='width:11%;'>Status :</td><td>" + objTicket.CurrentStatusValue + "</td></tr>";
                            emailBody += "<tr><td style='width:11%;'>Description :</td><td>" + model.IssueDescription + "</td></tr>";
                            emailBody += "</table>";
                            Helper.SendMail(model.PrimaryEmailAddress, MessageCollection.MatchbookTicketCreated, emailBody, SupportEmail);
                        }
                        else if (Helper.Branding == Branding.DandB.ToString())
                        {
                            emailBody += "Hi, " + model.EnteredBy + "<br/><br/>";
                            emailBody += MessageCollection.DandBTicketText + "<br/><br/>";
                            emailBody += "<table width='100%'>";
                            emailBody += "<tr><td style='width:11%;'>Title :</td><td>" + model.Title + "</td></tr>";
                            emailBody += "<tr><td style='width:11%;'>Priority :</td><td>" + objTicket.PriorityValue + "</td></tr>";
                            emailBody += "<tr><td style='width:11%;'>Status :</td><td>" + objTicket.CurrentStatusValue + "</td></tr>";
                            emailBody += "<tr><td style='width:11%;'>Description :</td><td>" + model.IssueDescription + "</td></tr>";
                            emailBody += "</table>";
                            Helper.SendMail(model.PrimaryEmailAddress, MessageCollection.DandBTicketCreated, emailBody, SupportEmail);
                        }
                        #endregion
                    }
                    SessionHelper.TicketMessage = CommonMessagesLang.msgCommanInsertMessage;
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
Esempio n. 6
0
    private string Authentication(Authentication Authobj)
    {
        string        ConnectionString = StringCipher.Decrypt(System.Configuration.ConfigurationManager.ConnectionStrings["GlobalMaster"].ConnectionString);
        SqlConnection con    = new SqlConnection(ConnectionString);
        string        conStr = "";
        DataSet       dsConn = new DataSet();

        con.Open();
        string mySQL = "SELECT wsu.WSUserCode, wsu.WSUserLoginId, wsu.WSUserPassword, CASE WHEN wsu.IsActive = 1 AND " +
                       " IsDeactivated = 0 THEN 1 ELSE 0 END AS IsActive, cm.ClientDBLocation, cm.ClientDB, cm.ClientDBUser, " +
                       " cm.ClientDBPass FROM WebServiceUsers AS wsu INNER JOIN ClientMaster AS cm ON wsu.clientID = cm.clientID " +
                       " WHERE (wsu.WSUserCode = '" + Authobj.VendorCode + "') AND (wsu.WSUserLoginId = '" + Authobj.UserName + "') " +
                       " AND (wsu.WSUserPassword = '******')";
        SqlCommand     cmd = new SqlCommand(mySQL, con);
        SqlDataAdapter ad  = new SqlDataAdapter(cmd);

        ad.Fill(dsConn);
        con.Close();
        if (dsConn.Tables[0].Rows.Count == 1 && Convert.ToBoolean(dsConn.Tables[0].Rows[0]["IsActive"]))
        {
            conStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString;
            conStr = string.Format(conStr, dsConn.Tables[0].Rows[0]["ClientDBLocation"].ToString(), dsConn.Tables[0].Rows[0]["ClientDB"].ToString(),
                                   dsConn.Tables[0].Rows[0]["ClientDBUser"].ToString(), dsConn.Tables[0].Rows[0]["ClientDBPass"].ToString());
            return(conStr);
        }
        else
        {
            return("");
        }
    }
Esempio n. 7
0
        public void CipherTests()
        {
            var toEncrypt = "hello";
            var password  = "******";
            var encypted  = StringCipher.Encrypt(toEncrypt, password);

            Assert.NotEqual(toEncrypt, encypted);
            var decrypted = StringCipher.Decrypt(encypted, password);

            Assert.Equal(toEncrypt, decrypted);

            var builder = new StringBuilder();

            for (int i = 0; i < 1000000; i++)             // check 10MB
            {
                builder.Append("0123456789");
            }

            toEncrypt = builder.ToString();
            encypted  = StringCipher.Encrypt(toEncrypt, password);
            Assert.NotEqual(toEncrypt, encypted);
            decrypted = StringCipher.Decrypt(encypted, password);
            Assert.Equal(toEncrypt, decrypted);
            Assert.Throws <CryptographicException>(() => StringCipher.Decrypt(encypted, ""));
            Assert.Throws <CryptographicException>(() => StringCipher.Decrypt(encypted, "wrongpassword"));

            toEncrypt = "foo@éóüö";
            password  = "";
            encypted  = StringCipher.Encrypt(toEncrypt, password);
            Assert.NotEqual(toEncrypt, encypted);
            decrypted = StringCipher.Decrypt(encypted, password);
            Assert.Equal(toEncrypt, decrypted);
            Assert.Throws <CryptographicException>(() => StringCipher.Decrypt(encypted, "wrongpassword"));
        }
Esempio n. 8
0
        public ActionResult ExportToCompanyData(ExportJobSettingsEntity objExport)
        {
            try
            {
                string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
                foreach (char c in invalid)
                {
                    objExport.FilePath = objExport.FilePath.Replace(c.ToString(), "");
                }
                objExport.ExportType    = ProviderType.DandB.ToString();// Set provider type DandB as it is from D & B
                objExport.ApplicationId = this.CurrentClient.ApplicationId;
                objExport.UserId        = Helper.oUser.UserId;
                objExport.FilePath      = objExport.FilePath + ".zip";
                if (Helper.oUser.UserRole == UserRole.LOB.ToString())
                {
                    objExport.LOBTag = Helper.oUser != null ? (Helper.oUser.LOBTag != null ? Helper.oUser.LOBTag : "") : "";
                }

                ExportJobSettingsFacade efac = new ExportJobSettingsFacade(StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["SolidQMasterWeb"].ConnectionString, General.passPhrase));
                efac.InserExportJobSettings(objExport);
                return(Json(new { result = true, message = ExportLang.msgExportDataSave }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new { result = false, message = CommonMessagesLang.msgCommanErrorMessage }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 9
0
        protected void ValidateUser(object sender, EventArgs e)
        {
            string Username = Login1.UserName;
            string Password = Login1.Password;

            if (!String.IsNullOrWhiteSpace(Username) && !String.IsNullOrWhiteSpace(Password))
            {
                try
                {
                    SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["NBeebyGamesConnection"].ConnectionString);
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("dbo.VALIDATE_USERS", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Username", SqlDbType.VarChar).Value = Username;
                    string password    = Convert.ToString(cmd.ExecuteScalar());
                    string decryptPass = StringCipher.Decrypt(password);
                    if (decryptPass == Password)
                    {
                        FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);
                        Response.Redirect("~/Portal/AccountPage.aspx");
                    }
                    else
                    {
                    }
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
                catch (Exception ex)
                {
                    string DBErrorMessage = "Could not execute stored procedure " + ex.Message;
                }
            }
        }
Esempio n. 10
0
        public JsonResult CancelExportProcess(int Id)
        {
            try
            {
                ExportJobSettingsFacade efac      = new ExportJobSettingsFacade(StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["SolidQMasterWeb"].ConnectionString, General.passPhrase));
                ExportJobSettingsEntity objExport = efac.GetExportJobSettingsByIdByClient(Id);   // MP-846 Admin database cleanup and code cleanup.-CLIENT

                if (objExport.ProcessStartDate == null)
                {
                    efac.CancelExportJobSettings(objExport);
                    SessionHelper.ExportView_Message = ExportLang.msgJobCancel;
                }
                else if (objExport.ProcessStartDate != null && !objExport.IsProcessComplete)
                {
                    SessionHelper.ExportView_Message = ExportLang.msgJobInProcess;
                }

                return(new JsonResult {
                    Data = CommonMessagesLang.msgSuccess
                });
            }
            catch (Exception ex)
            {
                SessionHelper.ExportView_Message = ex.Message.ToString();
                return(new JsonResult {
                    Data = CommonMessagesLang.msgFail
                });
            }
        }
Esempio n. 11
0
        public ActionResult LoadExportStatus(string Parameters)
        {
            string FileType = null;

            if (!string.IsNullOrEmpty(Parameters))
            {
                Parameters = StringCipher.Decrypt(Parameters.Replace(Utility.Utility.urlseparator, "+"), General.passPhrase);
                FileType   = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 0, 1);
            }
            FileType         = string.IsNullOrEmpty(FileType) ? CommonMessagesLang.lblMyFiles : FileType;
            ViewBag.FileType = FileType;
            int?UserId;

            if (FileType == CommonMessagesLang.lblMyFiles)
            {
                UserId = Helper.oUser.UserId;
            }
            else
            {
                UserId = null;
            }
            ExportJobSettingsFacade        efac          = new ExportJobSettingsFacade(StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["SolidQMasterWeb"].ConnectionString, General.passPhrase));
            List <ExportJobSettingsEntity> lstExportJobs = efac.GetExportJobSettingsByUserId(ProviderType.DandB.ToString(), UserId, this.CurrentClient.ApplicationId);

            return(PartialView("_index", lstExportJobs));
        }
Esempio n. 12
0
        public ActionResult ExportFileName(string Parameters)
        {
            string SrcRecID = "";

            if (!string.IsNullOrEmpty(Parameters))
            {
                SrcRecID = StringCipher.Decrypt(Parameters.Replace(Utility.Utility.urlseparator, "+"), General.passPhrase);
            }

            // Calling function for removing special characters
            SrcRecID = Utility.CommonMethod.RemoveSpecialChars(SrcRecID);

            //set the Export file name with domain ,srcid and datetime
            string url = Request.Url.Scheme + "://" + Request.Url.Authority + Url.Action("Login", "Account");

            string[] hostParts = new System.Uri(url).Host.Split('.');
            string   domain    = hostParts[0];
            string   filename  = "";

            filename         = domain + "_" + (string.IsNullOrEmpty(SrcRecID) ? "" : SrcRecID + "_") + DateTime.Now.ToString("yyyyMMddhhmmss");
            filename         = filename.TrimStart('_').TrimEnd('_');
            ViewBag.filename = filename;
            ViewBag.domain   = domain;
            ViewBag.SrcRecID = SrcRecID;
            ViewBag.SpanTime = DateTime.Now.ToString("yyyyMMddhhmmss");
            return(PartialView());
        }
Esempio n. 13
0
        public ActionResult LoadMonitoringExportStatus(string Parameters = null)
        {
            string MonitoringFileType = null;

            if (!string.IsNullOrEmpty(Parameters))
            {
                Parameters         = StringCipher.Decrypt(Parameters.Replace(Utility.Utility.urlseparator, "+"), General.passPhrase);
                MonitoringFileType = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 0, 1);
            }
            MonitoringFileType         = string.IsNullOrEmpty(MonitoringFileType) ? "My Files" : MonitoringFileType;
            ViewBag.MonitoringFileType = MonitoringFileType;

            int?UserId;

            if (MonitoringFileType == "My Files")
            {
                UserId = Helper.oUser.UserId;
            }
            else
            {
                UserId = null;
            }

            ExportJobSettingsFacade efac = new ExportJobSettingsFacade(StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["SolidQMasterWeb"].ConnectionString, General.passPhrase));
            List <MonitoringNotificationJobSettingsEntity> lstExportJobs = efac.GetMonitoringExportJobSettingsByUserId(UserId, this.CurrentClient.ApplicationId);

            return(PartialView("_MonitoringExport", lstExportJobs));
        }
Esempio n. 14
0
        public ActionResult MonitoringExportindex(string MonitoringFileType = null)
        {
            MonitoringFileType         = string.IsNullOrEmpty(MonitoringFileType) ? "My Files" : MonitoringFileType;
            ViewBag.MonitoringFileType = MonitoringFileType;

            int?UserId;

            if (MonitoringFileType == "My Files")
            {
                UserId = Helper.oUser.UserId;
            }
            else
            {
                UserId = null;
            }

            ExportJobSettingsFacade efac = new ExportJobSettingsFacade(StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["SolidQMasterWeb"].ConnectionString, General.passPhrase));
            List <MonitoringNotificationJobSettingsEntity> lstExportJobs = efac.GetMonitoringExportJobSettingsByUserId(UserId, this.CurrentClient.ApplicationId);

            // MP-1046 Create Individual URL redirection for all Tabs to make better format for URL
            if (Request.Headers["X-PJAX"] == "true")
            {
                return(PartialView("MonitoringExportindex", lstExportJobs));
            }
            else
            {
                ViewBag.SelectedTab = "MonitoringData";
                return(View("Index", lstExportJobs));
            }
        }
Esempio n. 15
0
        public string GetPassword(string id, SvcRepositoryType repositoryType, string passphrase)
        {
            // TODO: read document async and directly convert to model for a better performance
            var filter = Builders <BsonDocument> .Filter.Eq("_id", id);

            var document = base.collection.Find(filter).FirstOrDefault();

            if (document == null)
            {
                return(null);
            }

            var creds = document["RepositoryCredentials"].AsBsonArray;

            var credentials = new List <CredentialsWithPasswordDto>(creds.Count);

            credentials.AddRange(creds.Select(item => BsonSerializer.Deserialize <CredentialsWithPasswordDto>(item.AsBsonDocument)));

            CredentialsWithPasswordDto dto = credentials.FirstOrDefault(c => c.RepositoryType == repositoryType);

            if (dto == null)
            {
                Logging.Log().Debug($"Password for {id} user and {repositoryType} repository type not found.");
                return(null);
            }

            string decrypted = StringCipher.Decrypt(dto.Password, this.webApiConfiguration.SecretPassword);

            return(decrypted);
        }
        public void Import(byte[] file, string userId)
        {
            string content = "";

            try
            {
                string result = System.Text.Encoding.UTF8.GetString(file);
                content = StringCipher.Decrypt(result, Export_PrivateKey);
            }catch (Exception)
            {
                throw new BusinessException(Messages.LandingPage_Export_FileNotAllowed);
            }
            if (!content.Contains(Export_CheckKey))
            {
                throw new BusinessException(Messages.LandingPage_Export_FileNotAllowed);
            }
            content = content.Replace(Export_CheckKey, "");

            LandingPage ld = new LandingPage()
            {
                Id     = Guid.NewGuid(),
                UserId = userId,
                Name   = Export_LandingPage_Name,
                Source = content
            };

            IU(ld, "");
        }
Esempio n. 17
0
        private void HandleClient()
        {
            on_server_created();

            while (pEnable)
            {
                try
                {
                    var received_bytes = client_.Receive(ref ep_for_client_);

                    string request = StringCipher.Decrypt(Manager.sSingleton.ByteToString(received_bytes), Manager.SERVER_PROXY_KEY);

                    if (string.IsNullOrEmpty(request))
                    {
                        throw new Exception("empty request");
                    }

                    var response = Manager.sSingleton.StringToBytes(StringCipher.Encrypt(MakeResponse(request), Manager.SERVER_PROXY_KEY));

                    client_.Send(response, response.Length, ep_for_client_);
                }
                catch (Exception e)
                {
                    Manager.print("[error] server: " + e.Message);
                    break;
                }
            }
        }
Esempio n. 18
0
        public string Consultar(string key)
        {
            var valorCrypt = _context.HttpContext.Request.Cookies[key];
            var valor      = StringCipher.Decrypt(valorCrypt, _configuration.GetValue <string>("KeyCrypt"));

            return(valor);
        }
Esempio n. 19
0
        public void AuthenticateMessageTest()
        {
            var count      = 0;
            var errorCount = 0;

            while (count < 3)
            {
                var password  = "******";
                var plainText = "juan carlos";
                var encypted  = StringCipher.Encrypt(plainText, password);

                try
                {
                    // This must fail because the password is wrong
                    var t = StringCipher.Decrypt(encypted, "WRONG-PASSWORD");
                    errorCount++;
                }
                catch (CryptographicException ex)
                {
                    Assert.StartsWith("Message Authentication failed", ex.Message);
                }
                count++;
            }
            var rate = (double)errorCount / (double)count;

            Assert.True(rate <0.000001 && rate> -0.000001);
        }
Esempio n. 20
0
 public ActionResult TravelDocumentation(string id = "", string a = "", string p = "")
 {
     try
     {
         ViewBag.StudentID     = id;
         ViewBag.ApplicationNo = StringCipher.Decrypt(a);
         ViewBag.ProgramLevel  = p;
         TravelPlanRepository _objRepo = new TravelPlanRepository();
         DataSet _ds = _objRepo.SELECT_Student_TravelPlan_Status(ViewBag.StudentID);
         if (_ds != null)
         {
             if (_ds.Tables[0].Rows.Count > 0)
             {
                 foreach (DataRow _dr in _ds.Tables[0].Rows)
                 {
                     ViewBag.HasPassportDetails      = _dr["HasPassportDetails"].ToString();
                     ViewBag.HasAirTicketDetails     = _dr["HasAirTicketDetails"].ToString();
                     ViewBag.HasVisaDetails          = _dr["HasVisaDetails"].ToString();
                     ViewBag.HasInstituteSpocDetails = _dr["HasInstituteSpocDetails"].ToString();
                     ViewBag.IsAdmittedByInstitute   = _dr["IsAdmittedByInstitute"].ToString();
                 }
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(View());
 }
Esempio n. 21
0
    public static void Load()
    {
        if (!SaveExists)
        {
            throw new NullReferenceException();
        }

        var encryptedJson = File.ReadAllText(FullSavePath);
        var json          = StringCipher.Decrypt(encryptedJson, Key);

        var save = JsonConvert.DeserializeObject <Save>(json);

        PlayerController.Instance.Party              = save.Characters;
        PlayerController.Instance.Inventory          = save.Items;
        GameController.Instance.Globals              = save.Globals;
        GameController.Instance.Seeds                = save.Seeds;
        PlayerController.Instance.CurrentGold        = save.CurrentGold;
        PlayerController.Instance.CurrentExp         = save.CurrentExp;
        PlayerController.Instance.PartyLevel         = save.CurrentLevel;
        PlayerController.Instance.transform.position = save.ScenePosition;

        PlayerController.Instance.Party.ForEach(p => p.Regenerate());

        SceneManager.LoadScene(save.CurrentSceneIndex);
    }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.txtCode == StringCipher.Decrypt(model.hdnCode.ToString(), model.Email.ToString() + "A123b789"))
                {
                    // Attempt to register the user
                    MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);

                    if (createStatus == MembershipCreateStatus.Success)
                    {
                        FormsService.SignIn(model.UserName, true /* createPersistentCookie */);


                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
            return(View(model));
        }
Esempio n. 23
0
        private void btnEncriptarGrabar_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtConnectionString.Text.Trim()))
            {
                MessageBox.Show("Ingrese la cadena de conexión.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (String.IsNullOrEmpty(txtClaveRegistroGrabar.Text.Trim()))
            {
                MessageBox.Show("Ingrese la clave del registro.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var    connStr = StringCipher.Encrypt(txtConnectionString.Text, SMPorresEntities.ConnectionStringPassPhrase);
            string keyName = txtClaveRegistroGrabar.Text.Substring(0, txtClaveRegistroGrabar.Text.LastIndexOf("\\"));
            string value   = txtClaveRegistroGrabar.Text.Substring(txtClaveRegistroGrabar.Text.LastIndexOf("\\") + 1);

            Registry.SetValue(keyName, value, connStr);

            var v = (string)Registry.GetValue(keyName, value, "");
            var d = StringCipher.Decrypt(v, SMPorresEntities.ConnectionStringPassPhrase);

            if (txtConnectionString.Text.Equals(d) && IntentarConectar())
            {
                MessageBox.Show("La conexión se encriptó y grabó en el registro correctamente.", "Información",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("La conexión no se pudo encriptar y/o grabar correctamente.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 24
0
        public async Task <string> AsyncEncConversation(string msgOut)
        {
            string _msgIn;
            string _encMsg;

            try
            {
                _encMsg = StringCipher.Encrypt(msgOut);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Error encrypting message: {0}", ex.Message));
            }
            try
            {
                //_msgIn = SyncConversation(_encMsg);
                _msgIn = await AsyncConversation(_encMsg);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Error sending message: {0}", ex.Message));
            }
            try
            {
                return(StringCipher.Decrypt(_msgIn));
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Error receiving answer: {0}", ex.Message));
            }
        }
Esempio n. 25
0
        public ActionResult Edit(TicketEntity model)
        {
            ModelState.Remove("AssignedTo");
            if (ModelState.IsValid)
            {
                if (model != null)
                {
                    TicketFacade      tac        = new TicketFacade(StringCipher.Decrypt(Helper.GetMasterConnctionstring(), General.passPhrase));
                    TicketAuditEntity auditmodel = new TicketAuditEntity();

                    TicketEntity model1 = tac.GetLastTicketAuditByTicketIdByClient(model.Id);  // MP-846 Admin database cleanup and code cleanup.-CLIENT
                    auditmodel.AssignedTo = model.AssignedTo;
                    auditmodel.Priority   = model.Priority;
                    auditmodel.Status     = model1.CurrentStatus;// model.CurrentStatus;
                    auditmodel.Notes      = model.Note;
                    auditmodel.TicketId   = model.Id;
                    //Get Logged in User Name
                    auditmodel.ChangedByUser = Helper.UserName;
                    //Get Uploaded file name from tempdata
                    string Files = SessionHelper.ImageName;
                    //Save ticket data
                    tac.InsertUpdateTicketAuditForClient(auditmodel, model.PrimaryEmailAddress, model.PrimaryContactNumber, Files, model.Title, model.TicketType);   // MP-846 Admin database cleanup and code cleanup.-CLIENT
                    SessionHelper.TicketMessage = CommonMessagesLang.msgCommanUpdateMessage;
                    return(RedirectToAction("Index"));
                }
            }
            return(RedirectToAction("Edit", new { Parameters = StringCipher.Encrypt(model.Id.ToString(), General.passPhrase) }));
        }
Esempio n. 26
0
        /// <summary>
        /// Handle special features
        /// </summary>
        /// <returns>true if they are enabled</returns>
        static public bool AreSpecialFeaturesEnabled()
        {
            String owner = ConfigurationManager.AppSettings["owner"];

            if (owner == "")
            {
                return(false);
            }

            String key = ConfigurationManager.AppSettings["key"];
            bool   bOk = false;

            try
            {
                owner = _prefix + owner.ToLower() + _suffix;
                String decrypted = StringCipher.Decrypt(key, _password);
                if (decrypted.Contains(owner))
                {
                    bOk = true;
                }
            }
            catch (Exception)
            {
                bOk = false;
            }

            return(bOk);
        }
Esempio n. 27
0
        public ActionResult CloseTicket(int id, int pageNo, int pageSize)
        {
            TicketEntity objTicket = new TicketEntity();
            TicketFacade tac       = new TicketFacade(StringCipher.Decrypt(Helper.GetMasterConnctionstring(), General.passPhrase));

            objTicket = tac.GetTicketByIDByClients(id);  // MP-846 Admin database cleanup and code cleanup.-CLIENT
            TicketAuditEntity objAudit = new TicketAuditEntity();

            objAudit.Status        = 102005; // 102005=Closed
            objAudit.AssignedTo    = 0;
            objAudit.ChangedByUser = Helper.UserName;
            objAudit.Priority      = objTicket.Priority;
            objAudit.Notes         = objTicket.IssueDescription;
            objAudit.TicketId      = id;
            tac.InsertUpdateTicketAuditForClient(objAudit, null, null, null, null, 0);      // MP-846 Admin database cleanup and code cleanup.-CLIENT
            int finalsortOrder        = 12;
            int totalCount            = 0;
            List <TicketEntity> model = new List <TicketEntity>();

            //List all ticket
            model = tac.GetTicketListByUser(Request.Url.Authority, Helper.UserName, finalsortOrder, pageNo, pageSize, out totalCount).ToList();
            IPagedList <TicketEntity> pagedTicket = new StaticPagedList <TicketEntity>(model.ToList(), pageNo, pageSize, totalCount);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_Index", pagedTicket));
            }
            else
            {
                return(View("Index", pagedTicket));
            }
        }
Esempio n. 28
0
        //
        private ObservableCollection <ByflyClient> GetSavedCollection()
        {
            var collection   = new ObservableCollection <ByflyClient>();
            var profilesList = GetSavedProfiles();

            foreach (string profile in profilesList)
            {
                string login           = profile;
                string cryptedPassword = GetSavedPassword(Consts._SETTINGS_LOCATION + "\\" + Consts._PROFILES_LOCATION + "\\" + profile);
                string password        = "";
                if (cryptedPassword != null)
                {
                    try
                    {
                        password = StringCipher.Decrypt(cryptedPassword, Environment.MachineName + Environment.UserName + "lol");
                    }
                    catch (Exception ex)
                    {
                        _log.Error("Cannot decrypt saved password, wrong passPhrase or smthng: " + ex.Message);
                    }
                }

                collection.Add(new ByflyClient(login, password));
            }

            return(collection);
        }
Esempio n. 29
0
        private bool IsCorrectPassword()
        {
            string path = @"abc.dll";
            string s;

            using (StreamReader sr = File.OpenText(path))
            {
                s = sr.ReadLine();
            }

            string Password = AdminPasswordTextBox.Text;

            if (string.IsNullOrEmpty(Password))
            {
                PasswordInvalidLabel.Text = "Please enter valid administrator password...";
                return(false);
            }

            string decryptedstring = StringCipher.Decrypt(s);

            if (!decryptedstring.Equals(Password))
            {
                return(false);
            }
            return(true);
        }
Esempio n. 30
0
        public static string Decrypt(string input, bool getFromConfig = false)
        {
            if (input.IsEmpty())
            {
                return(string.Empty);
            }

            if (getFromConfig && TfSettings.Encryption.Active == false)
            {
                return(input);
            }

            StringCipher stringCipher = new StringCipher
            {
                PasswordHash = TfSettings.Encryption.PasswordHash,
                SaltKey      = TfSettings.Encryption.SaltKey,
                VIKey        = TfSettings.Encryption.VIKey
            };

            try
            {
                return(stringCipher.Decrypt(input));
            }
            catch
            {
                TfDebug.WriteLog(
                    TfSettings.Logs.System,
                    $"Ignored Invalid Decryption - {DateTime.Now}",
                    $"Value: {input}{Environment.NewLine}");

                return(null);
            }
        }