protected void Page_Load(object sender, EventArgs e) { string returnUrl = HttpUtility.UrlDecode(Request.QueryString["ru"]); ITicket ticket = BuildTicket(); if (string.IsNullOrEmpty(ticket.SignInInfo.UserID) == false) { XmlDocument xmlDoc = ticket.SaveToXml(); StringEncryption encryption = new StringEncryption(); byte[] encTicket = encryption.EncryptString(xmlDoc.OuterXml, PassportIntegrationSettings.GetConfig().GetDesKey()); string t = Convert.ToBase64String(encTicket); if (returnUrl != null) { string redirectUrl = returnUrl; if (returnUrl.LastIndexOf('?') >= 0) redirectUrl += "&"; else redirectUrl += "?"; redirectUrl += "t=" + HttpUtility.UrlEncode(t); Response.Redirect(redirectUrl); } else Helper.ShowTicketInfo(ticket, ticketInfo); } else Helper.ShowTicketInfo(ticket, ticketInfo); }
/// <summary> /// 解密票据 /// </summary> /// <param name="encryptedData"></param> /// <param name="oParam"></param> /// <returns></returns> public ITicket DecryptTicket(byte[] encryptedData, object oParam) { StringEncryption decoder = new StringEncryption(); string xml = decoder.DecryptString(encryptedData); return new Ticket(xml); }
protected void Page_Load(object sender, EventArgs e) { string t = Request.QueryString["t"]; if (string.IsNullOrEmpty(t)) RedirectToIntegrationPage(); else { byte[] encTicket = Convert.FromBase64String(t); StringEncryption encryption = new StringEncryption(); string ticketString = encryption.DecryptString(encTicket, PassportIntegrationSettings.GetConfig().GetDesKey()); Ticket ticket = new Ticket(ticketString); Helper.ShowTicketInfo(ticket, ticketInfo); ticketXml.InnerText = ticketString; } }
/// <summary> /// 加密票据 /// </summary> /// <param name="ticket"></param> /// <param name="oParam"></param> /// <returns></returns> public byte[] EncryptTicket(ITicket ticket, object oParam) { StringEncryption encoder = new StringEncryption(); return encoder.EncryptString(ticket.SaveToXml().InnerXml); }