Exemplo n.º 1
0
 public static string DecryptParameter( 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 objSecurity.Decrypt( strKey, Value );
 }
Exemplo n.º 2
0
 public static string DecryptParameter(string value, string encryptionKey)
 {
     var objSecurity = new PortalSecurity();
     //[DNN-8257] - Can't do URLEncode/URLDecode as it introduces issues on decryption (with / = %2f), so we use a modifed Base64
     value = value.Replace("_", "/");
     value = value.Replace("-", "+");
     value = value.Replace("%3d", "=");
     return objSecurity.Decrypt(encryptionKey, value);
 }
        private EventMessage DeserializeMessage( string filePath, string subscriberId )
        {
            EventMessage message = new EventMessage();
            StreamReader oStreamReader = File.OpenText( filePath );
            string messageString = oStreamReader.ReadToEnd();
            if( messageString.IndexOf( "EventMessage" ) < 0 )
            {
                PortalSecurity oPortalSecurity = new PortalSecurity();
                messageString = oPortalSecurity.Decrypt( EventQueueConfiguration.GetConfig().EventQueueSubscribers[subscriberId].PrivateKey, messageString );
            }
            message.Deserialize( messageString );
            oStreamReader.Close();

            //remove the persisted message from the queue if it has expired
            if( message.ExpirationDate < DateTime.Now )
            {
                File.Delete( filePath );
            }

            return message;
        }
Exemplo n.º 4
0
        /// <Summary>Does the replacement of tags on a givem message.</Summary>
        /// <Param name="MessageValue">The message to be formatted.</Param>
        /// <Param name="Prefix">The prefix to look for supported tags.</Param>
        /// <Param name="objObject">
        /// An object used to look for replacement values.
        /// </Param>
        /// <Param name="objType">
        /// Object type for the object used to look for replacement values.
        /// </Param>
        /// <Returns>The message with the found tags replaced.</Returns>
        private static string PersonalizeSystemMessage( string messageValue, string prefix, object objObject, Type objType )
        {
            string strPropertyValue = "";

            ArrayList objProperties = CBO.GetPropertyInfo(objType);

            for (int intProperty = 0; intProperty < objProperties.Count; intProperty++)
            {
                string strPropertyName = ((PropertyInfo)objProperties[intProperty]).Name;
                if (Strings.InStr(1, messageValue, "[" + prefix + strPropertyName + "]", CompareMethod.Text) != 0)
                {
                    PropertyInfo propInfo = (PropertyInfo)objProperties[intProperty];
                    object propValue = propInfo.GetValue(objObject, null);

                    if (propValue != null)
                    {
                        strPropertyValue = propValue.ToString();
                    }

                    // special case for encrypted passwords
                    if ((prefix + strPropertyName == "Membership:Password") && Convert.ToString(Globals.HostSettings["EncryptionKey"]) != "")
                    {
                        PortalSecurity objSecurity = new PortalSecurity();
                        strPropertyValue = objSecurity.Decrypt(Globals.HostSettings["EncryptionKey"].ToString(), strPropertyValue);
                    }

                    messageValue = Strings.Replace(messageValue, "[" + prefix + strPropertyName + "]", strPropertyValue, 1, -1, CompareMethod.Text);
                }
            }

            return messageValue;
        }