本文整理汇总了C#中DotNetNuke.Security.PortalSecurity.DecryptString方法的典型用法代码示例。如果您正苦于以下问题:C# PortalSecurity.DecryptString方法的具体用法?C# PortalSecurity.DecryptString怎么用?C# PortalSecurity.DecryptString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Security.PortalSecurity
的用法示例。
在下文中一共展示了PortalSecurity.DecryptString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFile
private void GetFile(string fileAction, string fileId)
{
string fileCheck = Localization.GetString("StoreFile", LocalResourceFile);
string postData = "";
Dictionary<string, string> settings = PortalController.GetPortalSettingsDictionary(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=" + username + "&password=" + 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();
}
}
}
示例2: OnLoad
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()); }
}
}
示例3: GetExtensions
protected void GetExtensions()
{
try
{
string fileCheck = Localization.GetString("StoreFile", LocalResourceFile);
string postData = "";
Stream oStream;
Dictionary<string, string> settings =
PortalController.GetPortalSettingsDictionary(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=" + username + "&password=" + password;
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 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;
}
XPathNavigator nav = oXMLDocument.CreateNavigator();
XPathNodeIterator iterator = nav.Select("orders/order/orderdetails/orderdetail");
int i = 0;
while (iterator.MoveNext())
{
//instance of a datarow
drow = dt.NewRow();
//add rows to datatable
dt.Rows.Add(drow);
string packageName = iterator.Current.GetAttribute("packagename", "").Replace("'", "''").Trim();
string fileName = iterator.Current.SelectSingleNode("files/file").GetAttribute("filename", "");
string fileId = iterator.Current.SelectSingleNode("files/file").GetAttribute("fileid", "");
string deploy = iterator.Current.SelectSingleNode("files/file").GetAttribute("deploy", "");
//add Column values
dt.Rows[i][dcol1] = packageName;
dt.Rows[i][dcol2] = fileName;
PortalSettings _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;
}
//.........这里部分代码省略.........
示例4: ProcessSnowcovered
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=" + username + "&password=" + 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;
}
示例5: GetSecureProfile
/// <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 "";
}
示例6: VerifyUser
/// <summary>
/// Tries to validate a verification code sent after a user is registered in a portal configured to use a verified registration.
/// </summary>
/// <param name="verificationCode">The verification code.</param>
/// <returns>An null string if the verification code has been validated and the user has been approved. An error message otherwise.</returns>
/// <exception cref="DotNetNuke.Entities.Users.UserAlreadyVerifiedException">Thrown when provided verification code has been already used.</exception>
/// <exception cref="DotNetNuke.Entities.Users.InvalidVerificationCodeException">Thrown when the provided verification code is invalid.</exception>
/// <exception cref="DotNetNuke.Entities.Users.UserDoesNotExistException">Thrown when the user does not exist.</exception>
public static void VerifyUser(string verificationCode)
{
Requires.NotNullOrEmpty("verificationCode", verificationCode);
var portalSecurity = new PortalSecurity();
var decryptString = portalSecurity.DecryptString(verificationCode, Config.GetDecryptionkey());
var strings = decryptString.Split('-');
if (strings.Length != 2)
{
throw new InvalidVerificationCodeException();
}
int portalId;
int userId;
if (!int.TryParse(strings[0], out portalId) || !int.TryParse(strings[1], out userId))
{
throw new InvalidVerificationCodeException();
}
var user = GetUserById(int.Parse(strings[0]), int.Parse(strings[1]));
if (user == null)
{
throw new UserDoesNotExistException();
}
if (user.Membership.Approved)
{
throw new UserAlreadyVerifiedException();
}
if (!user.IsInRole("Unverified Users"))
{
// A Registered User that has been unapproved has managed to get a valid verification code
throw new InvalidVerificationCodeException();
}
user.Membership.Approved = true;
UpdateUser(portalId, user);
ApproveUser(user);
}
示例7: UserSwitch
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);
}
}
}