public static WebDavFileUserTicket Parse(string strTicket) { bool?bWebDavTurnOn = PortalConfig.UseWebDav; string strRealData = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(strTicket)); string[] strSpitList = strRealData.Split('/'); if (strSpitList.Length < 4) { throw new ArgumentOutOfRangeException("strTicket"); } WebDavFileUserTicket retValue = new WebDavFileUserTicket( new DateTime(long.Parse(strSpitList[0]) * 0xc92a69c000), bWebDavTurnOn.HasValue && bWebDavTurnOn.Value ? int.Parse(strSpitList[1]) : -1, int.Parse(strSpitList[2]), strSpitList.Length > 4?int.Parse(strSpitList[3]):-1); if (retValue.ToString() != strTicket) { throw new ArgumentOutOfRangeException("strTicket"); } if (bWebDavTurnOn.HasValue && bWebDavTurnOn.Value && Security.CurrentUser == null) { // TODO: Check Ticket Expiration } return(retValue); }
public static string GetDownloadPath(int UserId, int FileId, string FileName, int HistoryInfoId) { bool?bWebDavTurnOn = PortalConfig.UseWebDav; // ASP.NET returns 400 Bad Request IF url includes: * & % .. // OZ [2007-09-27] Solve % char problem FileName = FileName.Replace("%", string.Empty); // OZ [2007-11-01] Solve & char problem FileName = FileName.Replace("&", string.Empty); //FileName = System.Web.HttpUtility.UrlPathEncode(FileName); if (bWebDavTurnOn.HasValue && bWebDavTurnOn.Value && IsWebDAVSupportedExtension(GetExtensionWithoutDot(FileName))) { WebDavFileUserTicket ticket = new WebDavFileUserTicket(UserId, FileId, HistoryInfoId); return(string.Format("/webdav/{0}/{1}", ticket.ToString(), FileName)); } else { WebDavFileUserTicket ticket = new WebDavFileUserTicket(-1, FileId, HistoryInfoId); return(string.Format("/files/{0}/{1}", ticket.ToString(), FileName)); } }
public static string GetDownloadPath(int UserId, int FileId, string FileName, int HistoryInfoId) { bool? bWebDavTurnOn = PortalConfig.UseWebDav; // ASP.NET returns 400 Bad Request IF url includes: * & % .. // OZ [2007-09-27] Solve % char problem FileName = FileName.Replace("%", string.Empty); // OZ [2007-11-01] Solve & char problem FileName = FileName.Replace("&", string.Empty); //FileName = System.Web.HttpUtility.UrlPathEncode(FileName); if (bWebDavTurnOn.HasValue && bWebDavTurnOn.Value && IsWebDAVSupportedExtension(GetExtensionWithoutDot(FileName))) { WebDavFileUserTicket ticket = new WebDavFileUserTicket(UserId, FileId,HistoryInfoId); return string.Format("/webdav/{0}/{1}", ticket.ToString(), FileName); } else { WebDavFileUserTicket ticket = new WebDavFileUserTicket(-1, FileId,HistoryInfoId); return string.Format("/files/{0}/{1}", ticket.ToString(), FileName); } }
public static WebDavFileUserTicket Parse(string strTicket) { bool? bWebDavTurnOn = PortalConfig.UseWebDav; string strRealData = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(strTicket)); string[] strSpitList = strRealData.Split('/'); if(strSpitList.Length<4) throw new ArgumentOutOfRangeException("strTicket"); WebDavFileUserTicket retValue = new WebDavFileUserTicket( new DateTime(long.Parse(strSpitList[0])*0xc92a69c000), bWebDavTurnOn.HasValue && bWebDavTurnOn.Value ? int.Parse(strSpitList[1]) : -1, int.Parse(strSpitList[2]), strSpitList.Length>4?int.Parse(strSpitList[3]):-1); if(retValue.ToString()!=strTicket) throw new ArgumentOutOfRangeException("strTicket"); if (bWebDavTurnOn.HasValue && bWebDavTurnOn.Value && Security.CurrentUser == null) { // TODO: Check Ticket Expiration } return retValue; }