public static string EncryptParameter( string Value ) { PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings(); string strKey = _portalSettings.GUID.ToString(); // restrict the key to 6 characters to conserve space PortalSecurity objSecurity = new PortalSecurity(); return HttpUtility.UrlEncode( objSecurity.Encrypt( strKey, Value ) ); }
public static string EncryptParameter(string value, string encryptionKey) { var objSecurity = new PortalSecurity(); string strParameter = objSecurity.Encrypt(encryptionKey, value); //[DNN-8257] - Can't do URLEncode/URLDecode as it introduces issues on decryption (with / = %2f), so we use a modifed Base64 strParameter = strParameter.Replace("/", "_"); strParameter = strParameter.Replace("+", "-"); strParameter = strParameter.Replace("=", "%3d"); return strParameter; }
public bool SendMessage( EventMessage message, string eventName, bool encryptMessage ) { //set the sent date if it wasn't set by the sender if( message.SentDate == DateTime.MinValue ) { message.SentDate = DateTime.Now; } string[] subscribers = new string[0]; if( EventQueueConfiguration.GetConfig().PublishedEvents[eventName] != null ) { subscribers = EventQueueConfiguration.GetConfig().PublishedEvents[eventName].Subscribers.Split( ";".ToCharArray() ); } else { subscribers[0] = ""; } //send a message for each subscriber of the specified event for( int indx = 0; indx <= subscribers.Length - 1; indx++ ) { StreamWriter oStream = File.CreateText( m_messagePath + MessageName( eventName, subscribers[indx], message.ID ) ); string messageString = message.Serialize(); if( encryptMessage ) { PortalSecurity oPortalSecurity = new PortalSecurity(); messageString = oPortalSecurity.Encrypt( EventQueueConfiguration.GetConfig().EventQueueSubscribers[subscribers[indx]].PrivateKey, messageString ); } oStream.WriteLine( messageString ); oStream.Close(); } return true; }
protected void Page_Load(object sender, EventArgs e) { try { //link for the Chat Archives //hlArchive.NavigateUrl = EditUrl("Archive",); StartMessage = Settings.Contains("StartMessage") ? Settings["StartMessage"].ToString() : Localization.GetString("DefaultStartMessage", LocalResourceFile); DefaultAvatarUrl = Settings.Contains("DefaultAvatarUrl") ? Settings["DefaultAvatarUrl"].ToString() : Localization.GetString("DefaultAvatarUrl", LocalResourceFile); var directRoom = string.Empty; var qs = Request.QueryString["rmid"]; if (qs != null) { directRoom = qs.ToString();} if (Settings.Contains("DefaultRoomId") && directRoom == string.Empty) { DefaultRoomId = Settings["DefaultRoomId"].ToString(); } else if (directRoom != string.Empty) { //if a guid came in, let's put the user in that room. DefaultRoomId = directRoom; } else { //if we don't have a setting. go get the default room from the database. var rc = new RoomController(); var r = rc.GetRoom("Lobby"); if (r == null || (r.ModuleId > 0 && r.ModuleId != ModuleId)) { //todo: if there isn't a room we need display a message about creating one } else { //if the default room doesn't have a moduleid on it, set the module id if (r.ModuleId < 0) { r.ModuleId = ModuleId; } rc.UpdateRoom(r); } if (r != null) DefaultRoomId = r.RoomId.ToString(); } //encrypt the user's roles so we can ensure security var curRoles = UserInfo.Roles; var section = (MachineKeySection)ConfigurationManager.GetSection("system.web/machineKey"); var pc = new PortalSecurity(); foreach (var c in curRoles) { EncryptedRoles += pc.Encrypt(section.ValidationKey, c) + ","; } if (UserInfo.IsSuperUser) { EncryptedRoles += pc.Encrypt(section.ValidationKey, "SuperUser"); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// AddPortal manages the Installation of a new DotNetNuke Portal /// </summary> /// <remarks> /// </remarks> public static int AddPortal(XmlNode node, bool status, int indent) { try { int intPortalId; string strHostPath = Globals.HostMapPath; string strChildPath = ""; string strDomain = ""; if (HttpContext.Current != null) { strDomain = Globals.GetDomainName(HttpContext.Current.Request, true).Replace("/Install", ""); } string strPortalName = XmlUtils.GetNodeValue(node, "portalname", ""); if (status) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Portal: " + strPortalName + "<br>"); } PortalController objPortalController = new PortalController(); PortalSecurity objSecurity = new PortalSecurity(); XmlNode adminNode = node.SelectSingleNode("administrator"); string strFirstName = XmlUtils.GetNodeValue(adminNode, "firstname", ""); string strLastName = XmlUtils.GetNodeValue(adminNode, "lastname", ""); string strUserName = XmlUtils.GetNodeValue(adminNode, "username", ""); string strPassword = XmlUtils.GetNodeValue(adminNode, "password", ""); string strEmail = XmlUtils.GetNodeValue(adminNode, "email", ""); string strDescription = XmlUtils.GetNodeValue(node, "description", ""); string strKeyWords = XmlUtils.GetNodeValue(node, "keywords", ""); string strTemplate = XmlUtils.GetNodeValue(node, "templatefile", ""); string strServerPath = Globals.ApplicationMapPath + "\\"; bool isChild = bool.Parse(XmlUtils.GetNodeValue(node, "ischild", "")); string strHomeDirectory = XmlUtils.GetNodeValue(node, "homedirectory", ""); //Get the Portal Alias XmlNodeList portalAliases = node.SelectNodes("portalaliases/portalalias"); string strPortalAlias = strDomain; if (portalAliases.Count > 0) { if (portalAliases[0].InnerText != "") { strPortalAlias = portalAliases[0].InnerText; } } //Create default email if (strEmail == "") { strEmail = "admin@" + strDomain.Replace("www.", ""); //Remove any domain subfolder information ( if it exists ) if (strEmail.IndexOf("/") != -1) { strEmail = strEmail.Substring(0, strEmail.IndexOf("/")); } } if (isChild) { strChildPath = strPortalAlias.Substring(strPortalAlias.LastIndexOf("/") + 1 - 1); } //Create Portal intPortalId = objPortalController.CreatePortal(strPortalName, strFirstName, strLastName, strUserName, objSecurity.Encrypt(Convert.ToString(Globals.HostSettings["EncryptionKey"]), strPassword), strEmail, strDescription, strKeyWords, strHostPath, strTemplate, strHomeDirectory, strPortalAlias, strServerPath, strServerPath + strChildPath, isChild); if (intPortalId > -1) { //Add Extra Aliases foreach (XmlNode portalAlias in portalAliases) { if (!String.IsNullOrEmpty(portalAlias.InnerText)) { if (status) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Portal Alias: " + portalAlias.InnerText + "<br>"); } objPortalController.AddPortalAlias(intPortalId, portalAlias.InnerText); } } } return intPortalId; } catch (Exception ex) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "<font color='red'>Error: " + ex.Message + "</font><br>"); return -1; // failure } }
/// <summary> /// cmdUpdate_Click runs when the Update button is clicked /// </summary> /// <history> /// [cnurse] 5/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> protected void cmdUpdate_Click( Object sender, EventArgs e ) { if( Page.IsValid ) { try { bool blnChild; string strMessage = String.Empty; string strPortalAlias; int intCounter; string strServerPath; string strChildPath = String.Empty; PortalController objPortalController = new PortalController(); PortalSecurity objSecurity = new PortalSecurity(); // check template validity ArrayList messages = new ArrayList(); string schemaFilename = Server.MapPath( "admin/Portal/portal.template.xsd" ); string xmlFilename = Globals.HostMapPath + cboTemplate.SelectedItem.Text + ".template"; PortalTemplateValidator xval = new PortalTemplateValidator(); if( ! xval.Validate( xmlFilename, schemaFilename ) ) { strMessage = Localization.GetString( "InvalidTemplate", this.LocalResourceFile ); lblMessage.Text = string.Format( strMessage, cboTemplate.SelectedItem.Text + ".template" ); messages.AddRange( xval.Errors ); lstResults.Visible = true; lstResults.DataSource = messages; lstResults.DataBind(); return; } //Set Portal Name txtPortalName.Text = txtPortalName.Text.ToLower(); txtPortalName.Text = txtPortalName.Text.Replace("http://", ""); //Validate Portal Name if( PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId ) { blnChild = true; // child portal for( intCounter = 1; intCounter <= txtPortalName.Text.Length; intCounter++ ) { if( "abcdefghijklmnopqrstuvwxyz0123456789-".IndexOf(txtPortalName.Text.Substring(intCounter, 1 )) == 0 ) { strMessage += "<br>" + Localization.GetString( "InvalidName", this.LocalResourceFile ); } } strPortalAlias = txtPortalName.Text; } else { blnChild = optType.SelectedValue == "C"; if( blnChild ) { strPortalAlias = txtPortalName.Text.Substring(txtPortalName.Text.LastIndexOf("/") + 1); } else { strPortalAlias = txtPortalName.Text; } string strValidChars = "abcdefghijklmnopqrstuvwxyz0123456789-"; if( ! blnChild ) { strValidChars += "./:"; } for( intCounter = 1; intCounter <= strPortalAlias.Length; intCounter++ ) { if (strValidChars.IndexOf(strPortalAlias.Substring(intCounter - 1, 1)) == 0) { strMessage += "<br>" + Localization.GetString( "InvalidName", this.LocalResourceFile ); } } } //Validate Password if( txtPassword.Text != txtConfirm.Text ) { strMessage += "<br>" + Localization.GetString( "InvalidPassword", this.LocalResourceFile ); } strServerPath = Globals.GetAbsoluteServerPath( Request ); //Set Portal Alias for Child Portals if( strMessage == "" ) { if( blnChild ) { strChildPath = strServerPath + strPortalAlias; if( Directory.Exists( strChildPath ) ) { strMessage = Localization.GetString( "ChildExists", this.LocalResourceFile ); } else { if( PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId ) { strPortalAlias = Globals.GetDomainName( Request ) + "/" + strPortalAlias; } else { strPortalAlias = txtPortalName.Text; } } } } //Get Home Directory string HomeDir; if( txtHomeDirectory.Text != "Portals/[PortalID]" ) { HomeDir = txtHomeDirectory.Text; } else { HomeDir = ""; } //Create Portal if( strMessage == "" ) { string strTemplateFile = cboTemplate.SelectedItem.Text + ".template"; //Attempt to create the portal int intPortalId; try { intPortalId = objPortalController.CreatePortal( txtTitle.Text, txtFirstName.Text, txtLastName.Text, txtUsername.Text, objSecurity.Encrypt( Convert.ToString( Globals.HostSettings["EncryptionKey"] ), txtPassword.Text ), txtEmail.Text, txtDescription.Text, txtKeyWords.Text, Globals.HostMapPath, strTemplateFile, HomeDir, strPortalAlias, strServerPath, strChildPath, blnChild ); } catch( Exception ex ) { intPortalId = Null.NullInteger; strMessage = ex.Message; } if( intPortalId != - 1 ) { // notification UserInfo objUser = UserController.GetUserByName( intPortalId, txtUsername.Text, false ); //Create a Portal Settings object for the new Portal PortalSettings newSettings = new PortalSettings(); newSettings.PortalAlias = new PortalAliasInfo(); newSettings.PortalAlias.HTTPAlias = strPortalAlias; newSettings.PortalId = intPortalId; string webUrl = Globals.AddHTTP( strPortalAlias ); try { if( PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId ) { Mail.SendMail( PortalSettings.Email, txtEmail.Text, PortalSettings.Email + ";" + Convert.ToString( PortalSettings.HostSettings["HostEmail"] ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objUser ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objUser ), "", "", "", "", "", "" ); } else { Mail.SendMail( Convert.ToString( PortalSettings.HostSettings["HostEmail"] ), txtEmail.Text, Convert.ToString( PortalSettings.HostSettings["HostEmail"] ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objUser ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objUser ), "", "", "", "", "", "" ); } } catch( Exception ) { strMessage = string.Format( Localization.GetString( "SendMail.Error", this.LocalResourceFile ), webUrl, null ); } EventLogController objEventLog = new EventLogController(); objEventLog.AddLog( objPortalController.GetPortal( intPortalId ), PortalSettings, UserId, "", EventLogController.EventLogType.PORTAL_CREATED ); // Redirect to this new site if( strMessage == Null.NullString ) { Response.Redirect( webUrl, true ); } } } lblMessage.Text = "<br>" + strMessage + "<br><br>"; } catch( Exception exc ) //Module failed to load { Exceptions.ProcessModuleLoadException( this, exc ); } } }