/// <summary> /// 驗證JWT /// </summary> /// <param name="token">JWT字串</param> /// <param name="signingCredentials">簽名鑰匙</param> /// <param name="result">剖析後的JWT結構</param> /// <returns>是否合法</returns> public static bool Verify( string token, SecurityKey signingCredentials, out IJwtToken <DefaultJwtHeader, dynamic> result) { var tempResult = new TempToken <dynamic>(); var returnValue = Verify <TempToken <dynamic>, DefaultJwtHeader, dynamic>(token, signingCredentials, out tempResult); result = tempResult; return(returnValue); }
/// <summary> /// 驗證JWT /// </summary> /// <typeparam name="TJwtPayload">內容類型</typeparam> /// <param name="token">JWT字串</param> /// <param name="signingCredentials">簽名鑰匙</param> /// <param name="result">剖析後的JWT結構</param> /// <param name="exception">例外</param> /// <returns>是否合法</returns> public static bool Verify <TJwtPayload>( string token, SecurityKey signingCredentials, out IJwtToken <DefaultJwtHeader, TJwtPayload> result, out Exception exception) { var tempResult = new TempToken <TJwtPayload>(); var returnValue = Verify <TempToken <TJwtPayload>, DefaultJwtHeader, TJwtPayload>(token, signingCredentials, out tempResult, out exception); result = tempResult; return(returnValue); }
public void reporteErrores() { SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = "Archivo PDF (*.pdf)|*.pdf"; saveFile.DefaultExt = "pdf"; saveFile.AddExtension = true; saveFile.Title = "Guardar Reporte Analisis Lexico"; if (saveFile.ShowDialog() == DialogResult.OK) { String path = saveFile.FileName; path = (path.EndsWith(".pdf")) ? path : path + ".pdf"; Document Report = new Document(); PdfWriter.GetInstance(Report, new FileStream(path, FileMode.Create)); Report.Open(); Report.Add(new Paragraph("REPORTE ANALISIS LEXICO", FontFactory.GetFont(FontFactory.HELVETICA, 20, BaseColor.BLUE))); Report.Add(new Paragraph("\n \n ")); PdfPTable Tabla1 = new PdfPTable(4); Tabla1.WidthPercentage = 100; PdfPCell titleCell = new PdfPCell(new Paragraph("ERRORES")); titleCell.Colspan = 8; titleCell.HorizontalAlignment = Element.ALIGN_CENTER; titleCell.BackgroundColor = BaseColor.LIGHT_GRAY; Tabla1.AddCell(titleCell); // COLUMNS NAMES Paragraph column1 = new Paragraph("ID", FontFactory.GetFont(FontFactory.HELVETICA, 12)); Paragraph column2 = new Paragraph("Lexema", FontFactory.GetFont(FontFactory.HELVETICA, 12)); Paragraph column3 = new Paragraph("Fila", FontFactory.GetFont(FontFactory.HELVETICA, 12)); Paragraph column4 = new Paragraph("Columna", FontFactory.GetFont(FontFactory.HELVETICA, 12)); Tabla1.AddCell(column1); Tabla1.AddCell(column2); Tabla1.AddCell(column3); Tabla1.AddCell(column4); foreach (Token TempToken in ListaErrores) { Tabla1.AddCell(TempToken.getID().ToString()); Tabla1.AddCell(TempToken.getLexema()); Tabla1.AddCell(TempToken.Fila.ToString()); Tabla1.AddCell(TempToken.Columna.ToString()); } Report.Add(Tabla1); Report.Close(); MessageBox.Show("Reporte de Errores Guardado Correctamente", "PDF", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public ActionResult Register([Bind(Include = "Email")] TempToken tokenObj) { //TODO ModelState.Remove("Token"); if (ModelState.IsValid) { //if (!String.IsNullOrWhiteSpace(email)) // TempData["LastTempMessage"] = SendAuthCodeToMember(email) ? "邮件已发送" : "邮件验证错误"; return(RedirectToAction("Login", "Temptoken")); } else { return(View()); } }
public ActionResult Login([Bind(Include = "Token")] TempToken tokenObj) { //TODO ModelState.Remove("Email"); if (ModelState.IsValid) { var dt = DateTime.Today; var cookies = XmlSetting.GetNodesByDate(ConfigEntity.NodeName, dt).ConvertAll(d => d?.Token); var aa = tokenObj.Token.ToSalt(ConfigEntity.tknSalt); if (!cookies.IsNullOrEmpty() && cookies.Contains(tokenObj?.Token.ToSalt(ConfigEntity.tknSalt))) { Response.Cookies[ConfigEntity.NodeName].Value = tokenObj.Token.ToSalt(ConfigEntity.tknSalt); //return RedirectToAction("Index", "Alarmnotes", new {date = Today}); return(RedirectToAction("Index", "Alarmnotes")); } ModelState.AddModelError("token", "Error Token"); } return(View()); }