private void UserSwitch() { if (Request.QueryString[FeatureController.QS_LOGINID] != null || Request.Cookies[FeatureController.QS_LOGINID] != null) { var loginid = string.Empty; if (Request.QueryString[FeatureController.QS_LOGINID] != null && PortalSettings.ActiveTab.TabID != PortalSettings.HomeTabId) { // run this if not on the homepage var qsValue = Request.QueryString[FeatureController.QS_LOGINID]; loginid = HttpUtility.UrlDecode(qsValue); // necessary because UrlDecode doesn't properly translate the decoded string loginid = loginid.Replace(" ", "+"); } else { // work around for a HTTP 301 redirect issue on homepages in DNN 07.01.00 // https://dnntracker.atlassian.net/browse/CONTENT-1561 loginid = Request.Cookies[FeatureController.QS_LOGINID].Value; } if (string.IsNullOrEmpty(loginid) == false) { var sec = new PortalSecurity(); // decrypt the id var userId = sec.DecryptString(loginid, PortalSettings.GUID.ToString()); int newUserId = int.Parse(userId, NumberStyles.Integer); ProcessLogin(newUserId); } } }
/// <summary> /// extract value base on naming container and key from PersonalizationInfo object /// function will automatically decrypt value to plaintext /// </summary> /// <param name="personalization">Object containing user personalization info</param> /// <param name="namingContainer">Container for related set of values</param> /// <param name="key">Individual profile key</param> /// <returns></returns> public static object GetSecureProfile(PersonalizationInfo personalization, string namingContainer, string key) { if (personalization != null) { var ps = new PortalSecurity(); return(ps.DecryptString(personalization.Profile[namingContainer + ":" + key].ToString(), Config.GetDecryptionkey())); } return(""); }
private void ProcessSnowcovered(string downloadURL, string installFolder, string catalogAction) { string fileCheck = downloadURL; string postData = ""; Stream oStream; Dictionary <string, string> settings = PortalController.GetPortalSettingsDictionary(ModuleContext.PortalId); PortalSecurity ps = new PortalSecurity(); string username = ps.DecryptString(settings["Store_Username"], Config.GetDecryptionkey()); string password = ps.DecryptString(settings["Store_Password"], Config.GetDecryptionkey()); postData = postData + "username="******"&password="******"&fileid=" + ViewState["fileId"].ToString(); WebRequest request = WebRequest.Create(fileCheck.ToString()); request.Method = "POST"; // Create POST data and convert it to a byte array. byte[] byteArray = Encoding.UTF8.GetBytes(postData); request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse response = request.GetResponse(); string myfile = ""; var cd = response.Headers["Content-Disposition"]; if (cd != null && cd.Trim() != "" && cd.StartsWith("inline;filename=")) { myfile = cd.Replace("inline;filename=", ""); } DownloadDeploy(response, myfile, installFolder, catalogAction); UI.Skins.Skin.AddModuleMessage(this, String.Format(GetString("deploySuccess"), ViewState["extName"]), ModuleMessage.ModuleMessageType.GreenSuccess); installExtension.NavigateUrl = Util.InstallURL(ModuleContext.TabId, "", ViewState["extType"].ToString(), myfile.ToLower().Replace(".zip", ".resources").ToString()); installExtension.Visible = true; deployExtension.Visible = false; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Page.IsPostBack) { PortalSecurity ps = new PortalSecurity(); Dictionary <string, string> settings = PortalController.GetPortalSettingsDictionary(ModuleContext.PortalId); if (settings.ContainsKey("Store_Username")) { txtUsername.Text = ps.DecryptString(settings["Store_Username"], Config.GetDecryptionkey()); } if (settings.ContainsKey("Store_Username")) { txtPassword.Text = ps.DecryptString(settings["Store_Password"], Config.GetDecryptionkey()); } } }
private void GetFile(string fileAction, string fileId) { string fileCheck = Localization.GetString("StoreFile", LocalResourceFile); string postData = ""; Dictionary <string, string> settings = PortalController.Instance.GetPortalSettings(ModuleContext.PortalId); var ps = new PortalSecurity(); string username = ps.DecryptString(settings["Store_Username"], Config.GetDecryptionkey()); string password = ps.DecryptString(settings["Store_Password"], Config.GetDecryptionkey()); postData = postData + "username="******"&password="******"&fileid=" + fileId; WebRequest request = WebRequest.Create(fileCheck); request.Method = "POST"; // Create POST data and convert it to a byte array. byte[] byteArray = Encoding.UTF8.GetBytes(postData); request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse wr = request.GetResponse(); string myfile = ""; string cd = wr.Headers["Content-Disposition"]; if (cd != null && cd.Trim() != "" && cd.StartsWith("inline;filename=")) { myfile = cd.Replace("inline;filename=", ""); } var objResponse = HttpContext.Current.Response; if (fileAction == "download") { objResponse.AppendHeader("Content-Disposition", "attachment; filename=\"" + myfile + "\""); objResponse.AppendHeader("Content-Length", wr.ContentLength.ToString()); objResponse.ContentType = wr.ContentType; const int bufferLength = 4096; byte[] byteBuffer = new byte[bufferLength]; Stream rs = wr.GetResponseStream(); int len = 0; while ((len = rs.Read(byteBuffer, 0, byteBuffer.Length)) > 0) { if (len < bufferLength) { objResponse.BinaryWrite(byteBuffer.Take(len).ToArray()); } else { objResponse.BinaryWrite(byteBuffer); } objResponse.Flush(); } } }
protected void GetExtensions() { try { string fileCheck = Localization.GetString("StoreFile", LocalResourceFile); string postData = ""; Stream oStream; Dictionary <string, string> settings = PortalController.Instance.GetPortalSettings(ModuleContext.PortalId); var ps = new PortalSecurity(); string username = ps.DecryptString(settings["Store_Username"], Config.GetDecryptionkey()); string password = ps.DecryptString(settings["Store_Password"], Config.GetDecryptionkey()); postData = postData + "username="******"&password="******"POST"; // Create POST data and convert it to a byte array. byte[] byteArray = Encoding.UTF8.GetBytes(postData); request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse response = request.GetResponse(); oStream = response.GetResponseStream(); XmlTextReader oReader; XPathDocument oXMLDocument; oReader = new XmlTextReader((oStream)); var dt = new DataTable(); //instance of a datarow DataRow drow; //creating two datacolums Column1 and Column2 var dcol1 = new DataColumn("Package", typeof(string)); var dcol2 = new DataColumn("Filename", typeof(string)); var dcol3 = new DataColumn("Download", typeof(string)); var dcol4 = new DataColumn("Deploy", typeof(string)); //adding datacolumn to datatable dt.Columns.Add(dcol1); dt.Columns.Add(dcol2); dt.Columns.Add(dcol3); dt.Columns.Add(dcol4); oReader.XmlResolver = null; try { oXMLDocument = new XPathDocument(oReader); } catch (Exception) { grdSnow.EmptyDataText = LocalizeString("NoData"); grdSnow.DataBind(); return; } var nav = oXMLDocument.CreateNavigator(); var orderDetailIterator = nav.Select("orders/order/orderdetails/orderdetail"); var i = 0; while (orderDetailIterator.MoveNext()) { var packageName = orderDetailIterator.Current.GetAttribute("packagename", "").Replace("'", "''").Trim(); var filesIterator = orderDetailIterator.Current.Select("files/file"); while (filesIterator.MoveNext()) { //instance of a datarow drow = dt.NewRow(); //add rows to datatable dt.Rows.Add(drow); var fileName = filesIterator.Current.GetAttribute("filename", ""); var fileId = filesIterator.Current.GetAttribute("fileid", ""); var deploy = filesIterator.Current.GetAttribute("deploy", ""); //add Column values dt.Rows[i][dcol1] = packageName; dt.Rows[i][dcol2] = fileName; var portalSettings = PortalController.Instance.GetCurrentPortalSettings(); dt.Rows[i][dcol3] = "<a class='dnnPrimaryAction' href='" + Globals.NavigateURL(portalSettings.ActiveTab.TabID, Null.NullString, "fileAction", "download", "fileid", fileId) + "'>" + LocalizeString("download") + "</a>"; if (deploy == "true") { dt.Rows[i][dcol4] = "<a class='dnnPrimaryAction' href=" + "\"" + ModuleContext.EditUrl("fileID", fileId, "Download", "package", Server.UrlPathEncode(packageName)) + "\"" + ">" + LocalizeString("deploy") + "</a>"; } else { dt.Rows[i][dcol4] = "N/A"; } i = i + 1; } } grdSnow.DataSource = dt; grdSnow.DataBind(); } catch (Exception) { grdSnow.EmptyDataText = LocalizeString("NoData"); grdSnow.DataBind(); } }