当前位置: 首页>>代码示例>>C#>>正文


C# PortalSecurity.Encrypt方法代码示例

本文整理汇总了C#中DotNetNuke.Security.PortalSecurity.Encrypt方法的典型用法代码示例。如果您正苦于以下问题:C# PortalSecurity.Encrypt方法的具体用法?C# PortalSecurity.Encrypt怎么用?C# PortalSecurity.Encrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetNuke.Security.PortalSecurity的用法示例。


在下文中一共展示了PortalSecurity.Encrypt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EncryptParameter

 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 ) );
 }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:7,代码来源:UrlUtils.cs

示例2: EncryptParameter

        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;
        }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:11,代码来源:UrlUtils.cs

示例3: SendMessage

        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;
        }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:33,代码来源:EventQueueController.cs

示例4: Page_Load

        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);
            }
        }
开发者ID:ChrisHammond,项目名称:dnnCHAT,代码行数:67,代码来源:View.ascx.cs

示例5: AddPortal

        /// <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 = "[email protected]" + 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
            }
        }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:95,代码来源:Upgrade.cs

示例6: cmdUpdate_Click


//.........这里部分代码省略.........
                    //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 );
                }
            }
        }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:101,代码来源:Signup.ascx.cs


注:本文中的DotNetNuke.Security.PortalSecurity.Encrypt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。