File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/CMSModules/REST/FormControls/GenerateHash.aspx.cs
using System;
using System.Text;
using System.Web;
using CMS.Helpers;
using CMS.WebServices;
using CMS.UIControls;
using CMS.Base;
public partial class CMSModules_REST_FormControls_GenerateHash : GlobalAdminPage
{
protected void Page_Load(object sender, EventArgs e)
{
PageTitle.TitleText = GetString("rest.generateauthhash");
btnAuthenticate.Text = GetString("rest.authenticate");
btnAuthenticate.Click += btnAuthenticate_Click;
}
protected void btnAuthenticate_Click(object sender, EventArgs e)
{
string[] urls = txtUrls.Text.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
StringBuilder newUrls = new StringBuilder();
foreach (string url in urls)
{
string urlWithoutHash = URLHelper.RemoveParameterFromUrl(url, "hash");
string newUrl = urlWithoutHash;
string query = URLHelper.GetQuery(newUrl).TrimStart('?');
int index = newUrl.IndexOfCSafe("/rest", true);
if (index >= 0)
{
string domain = URLHelper.GetDomain(newUrl);
newUrl = URLHelper.RemoveQuery(newUrl.Substring(index));
// Rewrite the URL to physical URL
string[] rewritten = BaseRESTService.RewriteRESTUrl(newUrl, query, domain, "GET");
newUrl = rewritten[0].TrimStart('~') + "?" + rewritten[1];
newUrl = HttpUtility.UrlDecode(newUrl);
// Get the hash from real URL
newUrls.AppendLine(URLHelper.AddParameterToUrl(urlWithoutHash, "hash", RESTService.GetHashForURL(newUrl, domain)));
}
else
{
newUrls.AppendLine(url);
}
}
txtUrls.Text = newUrls.ToString();
}
}